Page 1 of 2

sending a Backspace to a on Keyup commnd

Posted: Mon Sep 30, 2019 6:48 am
by chipsm
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?

Re: sending a Backspace to a on Keyup commnd

Posted: Mon Sep 30, 2019 10:55 am
by [-hh]
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

Re: sending a Backspace to a on Keyup commnd

Posted: Mon Sep 30, 2019 2:32 pm
by dunbarx
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

Re: sending a Backspace to a on Keyup commnd

Posted: Mon Sep 30, 2019 3:18 pm
by chipsm
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.

Re: sending a Backspace to a on Keyup commnd

Posted: Mon Sep 30, 2019 3:52 pm
by FourthWorld
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.

Re: sending a Backspace to a on Keyup commnd

Posted: Mon Sep 30, 2019 4:41 pm
by chipsm
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.

Re: sending a Backspace to a on Keyup commnd

Posted: Mon Sep 30, 2019 4:50 pm
by richmond62
Unicode Character 'BACKSPACE' (U+0008)

Re: sending a Backspace to a on Keyup commnd

Posted: Mon Sep 30, 2019 4:51 pm
by chipsm
can that be sent to a field? How?

Re: sending a Backspace to a on Keyup commnd

Posted: Mon Sep 30, 2019 5:14 pm
by FourthWorld
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

Re: sending a Backspace to a on Keyup commnd

Posted: Mon Sep 30, 2019 5:49 pm
by dunbarx
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

Re: sending a Backspace to a on Keyup commnd

Posted: Mon Sep 30, 2019 6:27 pm
by richmond62
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 11766 times
-
which, while being like some sort of minimalist art, is not what we want.

Re: sending a Backspace to a on Keyup commnd

Posted: Mon Sep 30, 2019 6:43 pm
by richmond62
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

Re: sending a Backspace to a on Keyup commnd

Posted: Mon Sep 30, 2019 7:17 pm
by chipsm
richmond2,
Sorry to cause your headache!
I will try this a bit later and let you know what happens.

Re: sending a Backspace to a on Keyup commnd

Posted: Mon Sep 30, 2019 8:04 pm
by dunbarx
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

Re: sending a Backspace to a on Keyup commnd

Posted: Mon Sep 30, 2019 9:04 pm
by chipsm
Hello, again richmond62.
I just tried your suggestion.
IT WORKS!
Forget the aspirin your Elixer works!
THANKS!