keyUp, rawKeyUp

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10096
Joined: Fri Feb 19, 2010 10:17 am

keyUp, rawKeyUp

Post by richmond62 » Fri Oct 25, 2024 9:19 am

Is it possible to have both of these in one script?

For instance:

Code: Select all

on rawKeyUp RKP
      put RKP into fld "myField1"
end rawKeyUp

on keyUp KUP
      put KUP into fld "myField2"
end keyUp
Possibly trying to be too clever for my own good I have a cardScript that contains a rawKeyDown, a rawKeyUp, and a keyUp statement . . . :oops:

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10096
Joined: Fri Feb 19, 2010 10:17 am

Re: keyUp, rawKeyUp

Post by richmond62 » Fri Oct 25, 2024 9:37 am

OK, OK: so I'm talking Bollo: can't be done.
-
TB.png
TB.png (61.21 KiB) Viewed 8832 times
-
HOWEVER; there must be another way to do this sort of thing . . .

This does NOT work:

Code: Select all

on rawKeyUp RU
   if the altKey is down then
      put RU into fld "feeld"
   else
keyUp KP
   put KP into fld "feeld"
end if
end rawKeyUp
as keyUp is NOT a command.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10096
Joined: Fri Feb 19, 2010 10:17 am

Re: keyUp, rawKeyUp

Post by richmond62 » Fri Oct 25, 2024 10:34 am

In the light of the scripts listed here I wonder if I can use a script with a different order:

viewtopic.php?t=4820

However, this:

Code: Select all

on keyUp KU
   put empty into fld "feeld"
   put KU after fld "feeld"
end keyUp

on rawKeyUp RU
      put RU after fld "feeld"
end rawKeyUp
does NOT work.

But this does:

Code: Select all

on keyDown KD
   put empty into fld "feeld"
end keyDown

on keyUp KU
   put KU after fld "feeld"
   pass keyUp
end keyUp

on rawKeyUp RU
   put RU after fld "feeld"
   pass rawKeyUp
end rawKeyUp
So, I discovered that for myself.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: keyUp, rawKeyUp

Post by dunbarx » Sat Oct 26, 2024 2:40 am

I have always found that these two "families" of messages do much the same thing, though "rawKeyUp" (or down) will be sent before keyUp (or down). In a card script on a new card with a field on it:

Code: Select all

on keyUp tkey
   if tKey = "102" then put random(999) into fld 1
end keyUp

on rawkeyUp tKey
   put tKey into fld 1
   wait 30
   keyUp --comment this out and keyUp works
   keyUp tkey --comment this out and keyUp fails
end rawkeyUp
You can see that the only reason "keyUp" works at all is that the original rawKeyUp parameter was explicitly passed to it. This might be exploited is a possibility. But if not, since both messages are indeed sent each keypress, poor "keyUp" is left without a parameter

Certainly the parameter sent with either family of messages is very different, and the way those parameters are characterized may be useful in their own right.

Craig
Last edited by dunbarx on Sat Oct 26, 2024 3:10 pm, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: keyUp, rawKeyUp

Post by dunbarx » Sat Oct 26, 2024 2:47 am

I should have started at the beginning. This:

Code: Select all

on keyUp 
   put random(999) into fld 1
end keyUp

on rawkeyUp tKey
   put tKey into fld 1
   wait 30
   keyUp tkey
end rawkeyUp
Places a number from both handlers, since no key-associated parameter is specified with the "keyUp" message. It just fires without context. Does this have a possible use? I do not think so, since whatever functionality it might offer could just as easily be placed in the "rawkeyUp" handler in the first place.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: keyUp, rawKeyUp

Post by dunbarx » Sat Oct 26, 2024 3:16 pm

Richmond.

I should have started at the real beginning, the one I first played around with, and then neglected. Everything I posted was based on it:

Code: Select all

on keyUp tkey
   if tKey = "D" then put random(999) into fld 1
end keyUp

on rawkeyUp tKey
   put tKey into fld 1
   wait 30
end rawkeyUp
For "rawKeyDown", tKey is 100, the code for "D". For "keyDown", tKey is simply "D". But "100" is the only thing that appears in the field. RawKeyDown, if trapped, seems to prevent keyDown.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10096
Joined: Fri Feb 19, 2010 10:17 am

Re: keyUp, rawKeyUp

Post by richmond62 » Sat Oct 26, 2024 5:23 pm

A rawKeyDown signal WILL prevent a keyDown signal unless you put a pass command in the code.

Post Reply