optionKeyDown - Community 6.6.1 - Windows

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
tetsuo29
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 106
Joined: Thu Jun 07, 2007 1:30 am

optionKeyDown - Community 6.6.1 - Windows

Post by tetsuo29 » Mon Apr 14, 2014 3:44 am

Hi all!

I've discovered what appears to be a bug with optionKeyDown and Windows.

The following works as expected on OS X:

Code: Select all

on optionKeyDown theKey
   --answer numToChar(charToNum(theKey) - 128)
   answer charToNum(theKey)
   if charToNum(theKey) = 182 then
      set the visible of button StopAskingCheck to true
      --   else
      --      set the visible of button StopAskingCheck to false
   end if
end optionKeyDown
(Note: the "answer charToNum(theKey)" is only there for my debugging efforts.)

What I'm doing is showing a checkbox on my donations nag window if the user presses Alt+d. On OS X this is working as expected.

However, on Windows the event fires even when no other key is down despite the documentation saying the following:
The optionKeyDown message is sent only when the user types a key combination that produces a character. For example, typing Option-F11 does not send an optionKeyDown message, because Option-F11 does not produce a character.
So, on Windows theKey always equals 54 (I guess this is the value of the Alt key by itself). I've tried this in the IDE and in a built application.

Is this a known error? Do I need to file a bug report? Suggestions for ways to code around it?

tetsuo29
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 106
Joined: Thu Jun 07, 2007 1:30 am

Re: optionKeyDown - Community 6.6.1 - Windows

Post by tetsuo29 » Mon Apr 14, 2014 3:55 am

Also, I tried the following:

Code: Select all

on keyDown theKey
   --answer numToChar(charToNum(theKey) - 128)
   if the optionKey is down then
     answer "The option key is down and theKey is: " & charToNum(theKey)
     if charToNum(theKey) = 182 then
        set the visible of button StopAskingCheck to true
        --   else
        --      set the visible of button StopAskingCheck to false
     end if
  else
     answer "The option key is up and theKey is: " & charToNum(theKey)
  end if
end keyDown
On Windows (7 that is), the keyDown event doesn't seem to fire when pressing alt+[some key]. I never get to the else clause that contains:

Code: Select all

  else
     answer "The option key is up and theKey is: " & charToNum(theKey)
Is it even possible to detect keyDown or optionKeyDown events properly on Windows 7 with LiveCode 6.6.1?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: optionKeyDown - Community 6.6.1 - Windows

Post by Simon » Tue Apr 15, 2014 2:19 am

Hi tetsuo29,
I have tested this and I'm seeing the same thing.
It doesn't seem right as I think it should act the same as commandKeyDown, but maybe not?

You can bug report it and see what they say (post the bug number here if you do).

"on optionKeyDown tKey"
tKey is never passed.

From the dictionary
The optionKeyDown message is sent when the user types a character while holding down the Option key (Mac OS systems), Meta key (Unix systems), or Alt key (Windows systems).
In experiments here, the message is sent as soon as the Alt key is pressed.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply