Simulate key press

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Simulate key press

Post by jacque » Sun Mar 13, 2016 5:32 pm

dunbarx wrote:Do you think this is worth mentioning? I have always been comforted by believing that an xTalk IDE was so flexible and accessible that, generically, " being able to invoke an arrowKey message under script control" was, simply, doable.

Did I mention that other instances of that pipe dream required kluges?
LC doesn't allow scripts to override its own messages, unlike HC, but that's a different thing. Are there other keywords that can't be "sent"? If so, then it's apparently intentional for some reason. If not, then it might be worth a mention.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Simulate key press

Post by richmond62 » Tue Jul 19, 2016 6:54 pm

As far as I can see the reason why it doesn't seem possible to invoke an arrowKey signal via script is
because, unlike a mouseDown the thing consists of 2 components:
code3.png
It might (?) be an idea to submit an enhancement request of this sort:

send "arrowKey"("up")

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

Re: Simulate key press

Post by richmond62 » Tue Jul 19, 2016 6:57 pm

Come to think of things, a series of this sort would be useful:

send "keyUp"("r")



send "rawKeyUp"(114)

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Simulate key press

Post by jacque » Tue Jul 19, 2016 7:10 pm

Try the "type" command?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Simulate key press

Post by richmond62 » Tue Jul 19, 2016 7:25 pm

I tried type.
type1.png
type1.png (6.19 KiB) Viewed 4487 times
and wondered how I would get the buttonScript to type "Аз харесам кашкавал"
by sending rawKey codes and having a Bulgarian keyboard layout selected on my computer.

This kind of banal and obvious script:
type2.png
type2.png (12.5 KiB) Viewed 4487 times
and
type3.png
type3.png (12.69 KiB) Viewed 4487 times
(Having checked that script: it does NOT work)

>>> work (and kudos to the Livecode people for everything working in a straightforward way
with a non-Latin writing system). <<<

How do I type the arrowKey "down"?
Last edited by richmond62 on Tue Jul 19, 2016 7:36 pm, edited 1 time in total.

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

Re: Simulate key press

Post by richmond62 » Tue Jul 19, 2016 7:34 pm

To explain in a little more detail:

Here's a cardScript:

on arrowKey AX
switch AX
case "up"
--do procedure #1
break
case "down"
--do procedure #2
break
end switch
end arrowKey

Now; how could I have a button which contains this sort of (pseudocode):

on mouseUp
send "arrowkey"("up") to card id 2001
end mouseUp

and, similarly with rawKey values?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Simulate key press

Post by jacque » Tue Jul 19, 2016 8:41 pm

I wouldn't think you need to send an arrowkey message at all. Just separate the actions from the handlers:

Code: Select all

on arrowKey AX
  switch AX
    case "up"
     procedure!
      break
    case "down"
     procedure2
      break
  end switch
end arrowKey

on mouseUp
  procedure1
end mouseUp

on procedure1
  -- stuff
end proceudre1

on procedure2
  --stuff
end proceudre2
Or you could combine them:

Code: Select all

on procedure pNum
  switch pNum
    case 1
      -- procedure 1 stuff
      break
    case 2
      -- procedure 2 stuff
      break
  end switch
end proedure
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply