sending a Backspace to a on Keyup commnd

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

chipsm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 244
Joined: Wed May 11, 2011 7:50 pm
Location: Southern California

sending a Backspace to a on Keyup commnd

Post by chipsm » Mon Sep 30, 2019 6:48 am

I have a need to simulate or even send a BackspaceKey to a field that is using a Keyup command.
just putting empty into the keyup focussed field does not work.
any help?
Clarence Martin
chipsm@themartinz.com

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: sending a Backspace to a on Keyup commnd

Post by [-hh] » Mon Sep 30, 2019 10:55 am

What does not work? The keyUp is here correctly sent ...

For example the mouseUp below puts 8 into fld 2, as expected:

Code: Select all

--script of fld 1
on keyUp k
   put charToNum(k) into fld 2
end keyUp

--script of btn 1
on mouseUp
   send "keyup numToChar(8)" to fld 1
end mouseUp
shiftLock happens

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: sending a Backspace to a on Keyup commnd

Post by dunbarx » Mon Sep 30, 2019 2:32 pm

Hi.

I am not sure I am saying this well, but you may need to drill deeper into LC's capabilities than "keyDown" can provide. Try this. Make two fields. In the script of fld 1:

Code: Select all

on  rawKeyDown tKey
   put tKey into fld 2
end rawKeyDown
Type into fld 1; you can isolate the backSpace key this way. Come back with what you think about it. Works as well with "rawKeyUp".

Craig

chipsm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 244
Joined: Wed May 11, 2011 7:50 pm
Location: Southern California

Re: sending a Backspace to a on Keyup commnd

Post by chipsm » Mon Sep 30, 2019 3:18 pm

Hi all.
Let me explain this a little better.
I am trying to send the backspacekey from another button to a field that has the keyup function.
I trapped the backSpace key so that I can get the keyboard ASCII code for backspace by trapping the pkey on the on MouseUp.
I was hoping to be able to send that to the field.
This is kind of complicated.
I use the backspace key with the "On keyUp" field to set up another field to do things. It works using the keyboard and that is what I want to simulate.
Clarence Martin
chipsm@themartinz.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9824
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: sending a Backspace to a on Keyup commnd

Post by FourthWorld » Mon Sep 30, 2019 3:52 pm

Backspace is among the non-printing keys which are not sent with keyUp. Why not use the backspaceKey message? If you have to use a generic handler see rawKeyUp.

Alternatively, do you need to send a keyboard message to do what you want to do? If you want to delete characters based on the selection you could do that directly without having to route that outcome through extra messages.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

chipsm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 244
Joined: Wed May 11, 2011 7:50 pm
Location: Southern California

Re: sending a Backspace to a on Keyup commnd

Post by chipsm » Mon Sep 30, 2019 4:41 pm

Hi Richard,
I have "put empty into the field" it does not have the same effect as a backspace key- in my case.
This is one that I will show the Pasadena User Group as a CHALLENGE. It may be my logic or lack of logic that's the problem.
I introduced my custom dropdown list field last meeting and this list option is where the problem shows up.
Clarence Martin
chipsm@themartinz.com

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: sending a Backspace to a on Keyup commnd

Post by richmond62 » Mon Sep 30, 2019 4:50 pm

Unicode Character 'BACKSPACE' (U+0008)

chipsm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 244
Joined: Wed May 11, 2011 7:50 pm
Location: Southern California

Re: sending a Backspace to a on Keyup commnd

Post by chipsm » Mon Sep 30, 2019 4:51 pm

can that be sent to a field? How?
Clarence Martin
chipsm@themartinz.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9824
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: sending a Backspace to a on Keyup commnd

Post by FourthWorld » Mon Sep 30, 2019 5:14 pm

chipsm wrote:
Mon Sep 30, 2019 4:41 pm
I have "put empty into the field" it does not have the same effect as a backspace key- in my case.
True, emptying an entire field is not the same as deleting the selection. But if you want to delete the selected text you could use:

Code: Select all

put empty into the selectedText
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: sending a Backspace to a on Keyup commnd

Post by dunbarx » Mon Sep 30, 2019 5:49 pm

Doesn't the OP simply want to remotely delete the last char of the field? That is what backspace would do if typed directly.

@Chip(?)

Might you simply rethink this and:

Code: Select all

on mouseUp
  -- or any part of any handler anywhere
  delete the last char of fld "yourField"
  select after fld "yourField"
  end mouseUp
???

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: sending a Backspace to a on Keyup commnd

Post by richmond62 » Mon Sep 30, 2019 6:27 pm

Reading the original OP again it is far from clear they want to delete the LAST char.

I do think they want to delete the char just in front of the cursor insertion.

The snag about this is if the field allows the end-user to insert an insertion point (wow: there's some
dicky grammar) into a textField that also means that when the end-user sends a keyUp the
field will receive focus and, at the very least,either receive a keyDown or the SIMPLE delete signal.

Aiblins s/he is speirin after something else, whereby the insertion point has been determined in some other
way, and still wants to delete the char just in front of the cursor insertion.

This is what we should be looking at.

The Unicode "thing" for backspace is either: U+0008 or U+2408 . . .

Code: Select all

on keyUp KUP
   if KUP = "\" then
      put numToCodePoint(0x8) after field "ff"
   else
      --do nix
      end if
end keyUp
does nothing.

This:

Code: Select all

on keyUp KUP
   if KUP = "\" then
      put numToCodePoint(0x2408) after field "ff"
   else
      --do nix
      end if
end keyUp
does this:
-
Screenshot 2019-09-30 at 20.22.25.png
Screenshot 2019-09-30 at 20.22.25.png (16.53 KiB) Viewed 9344 times
-
which, while being like some sort of minimalist art, is not what we want.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: sending a Backspace to a on Keyup commnd

Post by richmond62 » Mon Sep 30, 2019 6:43 pm

What IS needed here is a way to send a backspaceKey message.

Ouch: I can feel a headache coming on:

Code: Select all

on keyUp KUP
   if KUP = "\" then
      select after field "ff"
      type numToCodePoint(0x8)
      type numToCodePoint(0x8)
   else
      --do nix
   end if
end keyUp

chipsm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 244
Joined: Wed May 11, 2011 7:50 pm
Location: Southern California

Re: sending a Backspace to a on Keyup commnd

Post by chipsm » Mon Sep 30, 2019 7:17 pm

richmond2,
Sorry to cause your headache!
I will try this a bit later and let you know what happens.
Clarence Martin
chipsm@themartinz.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: sending a Backspace to a on Keyup commnd

Post by dunbarx » Mon Sep 30, 2019 8:04 pm

Reading the original OP again it is far from clear they want to delete the LAST char.

I do think they want to delete the char just in front of the cursor insertion.
The char just behind...?

OK. Still not sure why the backSpaceKey message is required. Not that it cannot be made to work, but is it going to be always robust?

So how about this:

Code: Select all

on mouseUp
   put word 4 of the selectedchunk into oldCharPos
   delete char oldCharPos of fld "yourField"
   select after char oldCharPos of fld "yourField"
end mouseUp
Craig

chipsm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 244
Joined: Wed May 11, 2011 7:50 pm
Location: Southern California

Re: sending a Backspace to a on Keyup commnd

Post by chipsm » Mon Sep 30, 2019 9:04 pm

Hello, again richmond62.
I just tried your suggestion.
IT WORKS!
Forget the aspirin your Elixer works!
THANKS!
Clarence Martin
chipsm@themartinz.com

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”