Page 1 of 1

Key commands not recognised

Posted: Tue Aug 25, 2020 2:24 pm
by odysseus
I am using Livecode on an iMac. the 'commandKeyDown' and 'escapeKey' commands don't work, they throw up an error when put into a script. The escapeKey doesn't work with 'keyDown' either. Any ideas?

Re: Key commands not recognised

Posted: Tue Aug 25, 2020 2:38 pm
by richmond62
Indeed:

Mac Mini
LC 9.6.1
macOS 11.0 Beta 5

Code: Select all

on keyDown KD
   if the commandKey is down then
      put "cmdkey Down" into fld "fff"
   end if
end keyDown

on keyUp KP
   put empty into fld "fff"
end keyUp
does nothing at all.

Wonder about a bug report?

However
:

this worked:

Code: Select all

on escapeKey
   put "Yabba-dabba-doo" into fld "fff"
end escapeKey

Re: Key commands not recognised

Posted: Tue Aug 25, 2020 4:43 pm
by FourthWorld
odysseus wrote:
Tue Aug 25, 2020 2:24 pm
the 'commandKeyDown' and 'escapeKey' commands don't work, they throw up an error when put into a script.
Error messages provide guidance. What does the message you encounter say?

Re: Key commands not recognised

Posted: Wed Aug 26, 2020 9:40 pm
by odysseus
CommandKeyDown is supposed to check if another key is pressed with the command key, according to the livecode dictionary, but isn’t recognised in a script, prompting a red cross. I even copied the script in the dictionary to no avail.
Similarly the escapeKey also produces a red cross.

Re: Key commands not recognised

Posted: Thu Aug 27, 2020 9:16 am
by richmond62
Well; here's a thought . . .

If I set up a stack with a field and this in the cardScript:

Code: Select all

on keyDown KD
   if the commandKey is down then 
      put "Yup" into fld "Um"
   else
      put empty into fld "Um"
      end if
end keyDown
and I press Command + 'f', the "Find" thingy of LiveCode comes up,
and so on and so forth with ALL the key commands in the LiveCode IDE.

This obviously means that when the commandKey is pressed all things are trapped by the IDE before they get to the cardScript.

I have reported exactly this here: https://quality.livecode.com/show_bug.cgi?id=22881

Re: Key commands not recognised

Posted: Thu Aug 27, 2020 9:23 am
by LCMark
@odysseus: commandKeyDown and escapeKey are events to be handled, not commands to be executed. i.e.

Code: Select all

on keyDown pKey
  answer "The user pressed" && pKey
end keyDown

on commandKeyDown pKey
  answer "The user pressed Cmd+" & pKey
end commandKeyDown

on escapeKey
  answer "The user pressed escape"
end escapeKey
Note: You won't get both keyDown and commandKeyDown - you get the former if Cmd is not held down, and the latter if it is.

Re: Key commands not recognised

Posted: Thu Aug 27, 2020 9:35 am
by richmond62
I almost love you. 8)

Code: Select all

on commandKeyDown CKD
   put "Yup" into fld "Um"
end commandKeyDown

Re: Key commands not recognised

Posted: Thu Aug 27, 2020 6:45 pm
by odysseus
I understand they are events, my title was misleading, but the point is that on my system ‘on commandKeyDown’ is not recognised at all and causes the red cross to be shown, so the script will obviously not compile.

Re: Key commands not recognised

Posted: Thu Aug 27, 2020 7:41 pm
by richmond62
Dunno: this works with me:

[macOS 11.0 beta 5, LiveCode 9.6.1]

Code: Select all

on commandKeyDown KD
      put KD into fld "ff"
end commandKeyDown
-
Screenshot 2020-08-27 at 21.39.16.png
Screenshot 2020-08-27 at 21.39.16.png (20.97 KiB) Viewed 3072 times
-
Mind you; I have a "funny feeling" about pKey. 8)

Re: Key commands not recognised

Posted: Tue Sep 01, 2020 2:30 pm
by dunbarx
...the point is that on my system ‘on commandKeyDown’ is not recognised at all and causes the red cross to be shown, so the script will obviously not compile.
Do you mean that this will not stand happily in the SE?

Code: Select all

on commandkeyDown
end commandKeyDown
Craig

Re: Key commands not recognised

Posted: Tue Sep 01, 2020 7:24 pm
by richmond62
Ihope you haven't "been bonkers" like me
and messed around with your modifier keys settings:
-
Screenshot 2020-09-01 at 21.23.16.png