Using a mneonic of m
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Using a mneonic of m
I can create a stack with a regular push button on it with a label of "Manual" and mnemonic of 1, so that it will be the letter "m". This is the only change from a regular push button that has been dragged off of the tools menu. Therefore I expect to be able to press Alt-m and the button will act as if it was clicked. This works perfectly fine as I expect it to.
However, the part that does not work as expected is when I press control and the numpad minus sign. This also causes the mouseUp event to be sent to the button. It does not happen with control and the minus sign on the keyboard next to the 0 key. Does anyone know why the control-keypad minus sign acts the same as the Alt-m keypress?
Other notes: If the letter for the mnemonic is not m then control-keypad minus does nothing. It does not matter which letter in the name/label the 'm' is in. (If I set the name to "name" and the mnemonic to 3 the unexpected behavior still happens). This was tested on Windows with versions 4.5 and 4.6.4.
The whole reason for this is that I want to have a button which uses a mnemonic of 'm' but also have control-either minus sign do something else.
However, the part that does not work as expected is when I press control and the numpad minus sign. This also causes the mouseUp event to be sent to the button. It does not happen with control and the minus sign on the keyboard next to the 0 key. Does anyone know why the control-keypad minus sign acts the same as the Alt-m keypress?
Other notes: If the letter for the mnemonic is not m then control-keypad minus does nothing. It does not matter which letter in the name/label the 'm' is in. (If I set the name to "name" and the mnemonic to 3 the unexpected behavior still happens). This was tested on Windows with versions 4.5 and 4.6.4.
The whole reason for this is that I want to have a button which uses a mnemonic of 'm' but also have control-either minus sign do something else.
Re: Using a mneonic of m
I think i understand you correctly, you want to have (ctrl & "-") keys initialize a given script when pressed?
Maybe you have a handler on your card such as keyDown/KeyUp, along with the "-" key!? Otherwise, i dont see how the engine is confusing the keys "m" and "-" on your system.
If the above idea isnt the case; ie, if you dont have your card or stack receiving keyDown/KeyUp messages, you might try to intercept them as indicated.
Script for card:
(note - "keyDown" or "keyUp" should work with example above)
Hope it helps!
Maybe you have a handler on your card such as keyDown/KeyUp, along with the "-" key!? Otherwise, i dont see how the engine is confusing the keys "m" and "-" on your system.
If the above idea isnt the case; ie, if you dont have your card or stack receiving keyDown/KeyUp messages, you might try to intercept them as indicated.
Script for card:
Code: Select all
on keyDown tKey
If controlKey() is down then
if tKey is "-" then
-- code desired
exit to top
end if
end if
pass keyDown
end keyDown
Hope it helps!
Chris Bodell
Photo Room - (Editor Download)
Photo Room - (Editor Download)
Re: Using a mneonic of m
I have now tried the following on 3 different Windows machines running 3 different versions of livecode (4.5, 4.6.4, and 5.0) on a brand new stack that is otherwise completely blank.
If I press control and any of the numbers above the letters it prints what I expect. But then it gets weird. The following list documents what key I pressed and then what character showed up in the message box. (KB stands for keys on the main part of the keyboard and NP stands for keys on the numpad section)
KB "-", the fractional symbol 1/2 (unicode point U+00BD)
KB "=", the double right guillemet used as quotation marks in some countries (unicode point U+00BB)
KB ",", the fractional symbol 1/4 (unicode point U+00BC)
KB "/", inverted question mark (unicode point U+00BF)
NP "0", "`" (the backwards tick found above tab on US keyboards)
NP "1", "a"
NP "2", "b"
NP "3", "c"
.....
NP "9", "i"
NP "*", "j"
NP "+", "k"
NP "-", "m"
NP ".", "n"
NP "/", "o"
It is interesting to note that the numbers pressed on the keypad, the difference in the ASCII table between what was displayed and what was pressed is 0x30 while the difference for the non-numeric characters is 0x40. I don't understand the relationship for the main keyboard characters.
The end result is that somehow by pressing the control key, the '-' character on the numpad gets turned into a 'm' as far as the livecode engine is concerned. If i use the rawkeyup message, I can tell that it was the minus sign that was pressed on the numpad since it comes across with a raw key code of 65453 (which is the ascii code for '-' with the top 9 bits set) and therefore do what I want to do when the user pressed Control and "-".
However, since it still gets interpreted as the letter 'm' by the engine, that also sends the mouseup message to any button with a mnemonic of 'm'. Also this means that the documentation for the mnemonic keyword is wrong since it claims the mouseup message is sent only when the Alt key is down and that character is pressed when actually the Alt key does not need to be pressed. (I tested this separately also). I cant think of any way to determine in the mouseup message that it was actually the "-" key on the numpad that caused the mnemonic to trigger and not the actual "m" key. If there was some way to do that then I could get around all of this weirdness and I would be happy.
Sorry for that being a whole lot longer than expected.
Code: Select all
on keydown tkey
if controlkey() is down then
put "The key is " & quote & tkey & quote
end if
end keydown
KB "-", the fractional symbol 1/2 (unicode point U+00BD)
KB "=", the double right guillemet used as quotation marks in some countries (unicode point U+00BB)
KB ",", the fractional symbol 1/4 (unicode point U+00BC)
KB "/", inverted question mark (unicode point U+00BF)
NP "0", "`" (the backwards tick found above tab on US keyboards)
NP "1", "a"
NP "2", "b"
NP "3", "c"
.....
NP "9", "i"
NP "*", "j"
NP "+", "k"
NP "-", "m"
NP ".", "n"
NP "/", "o"
It is interesting to note that the numbers pressed on the keypad, the difference in the ASCII table between what was displayed and what was pressed is 0x30 while the difference for the non-numeric characters is 0x40. I don't understand the relationship for the main keyboard characters.
The end result is that somehow by pressing the control key, the '-' character on the numpad gets turned into a 'm' as far as the livecode engine is concerned. If i use the rawkeyup message, I can tell that it was the minus sign that was pressed on the numpad since it comes across with a raw key code of 65453 (which is the ascii code for '-' with the top 9 bits set) and therefore do what I want to do when the user pressed Control and "-".
However, since it still gets interpreted as the letter 'm' by the engine, that also sends the mouseup message to any button with a mnemonic of 'm'. Also this means that the documentation for the mnemonic keyword is wrong since it claims the mouseup message is sent only when the Alt key is down and that character is pressed when actually the Alt key does not need to be pressed. (I tested this separately also). I cant think of any way to determine in the mouseup message that it was actually the "-" key on the numpad that caused the mnemonic to trigger and not the actual "m" key. If there was some way to do that then I could get around all of this weirdness and I would be happy.
Sorry for that being a whole lot longer than expected.
Re: Using a mneonic of m
That's definitely interesting, you might try to turn off you "NumLock" setting, from the keyboard, im not quite sure, but that may send the rawValue of the key differently.
Alternatively, one thing you could do: It seems that the raw value of the key is retrieved correctly? If thats so you might try to intercept the "key combination" there, then cancel out any further code obligation by "exiting" the handler, not "passing". But if the key combo is still sending the mouseUp handler, try "inserting" the script with the keyUp/KeyDown handlers into front, then "exiting" the handler. That may work.
You might also try intercepting the rawKey codes in a handler specifically for the numpad and cancel out the functions. So then you'd only be able to use the number keys above the character keys?! Might work.
I havent tested this, but that would be my guess. Unless you need the keys from the numpad to be reserved/used.
*the operating system handles the ralationship between ASCII char values & keys. ie, "Alt/Ctrl" key and numpad key combos, so i'm sure it wouldn't be the engine. If the above does not work, you might have to find other combonations of keys to replace your ("ctrl" & "-") needs.
But Definitely try to insert the script into front then test/intercept the key handlers from there.
Good Luck!
Alternatively, one thing you could do: It seems that the raw value of the key is retrieved correctly? If thats so you might try to intercept the "key combination" there, then cancel out any further code obligation by "exiting" the handler, not "passing". But if the key combo is still sending the mouseUp handler, try "inserting" the script with the keyUp/KeyDown handlers into front, then "exiting" the handler. That may work.
You might also try intercepting the rawKey codes in a handler specifically for the numpad and cancel out the functions. So then you'd only be able to use the number keys above the character keys?! Might work.
I havent tested this, but that would be my guess. Unless you need the keys from the numpad to be reserved/used.
*the operating system handles the ralationship between ASCII char values & keys. ie, "Alt/Ctrl" key and numpad key combos, so i'm sure it wouldn't be the engine. If the above does not work, you might have to find other combonations of keys to replace your ("ctrl" & "-") needs.
But Definitely try to insert the script into front then test/intercept the key handlers from there.
Good Luck!
Chris Bodell
Photo Room - (Editor Download)
Photo Room - (Editor Download)
Re: Using a mneonic of m
So I implemented a very crude hack to get it to work. I added a front script that has a rawkeydown and a rawkeyup handler. In the rawkeydown handler I say if the keypress came from the numpad then disable the mnemonic of the button and on rawkeyup then enable the mnemonic. There were other issues I had to deal with since the stack where this is uses is normally one of many stacks that is open but I got around that. The only thing that isnt perfect about this is that the underline underneath the 'm' on the button will flash off and on which is a little annoying but Im not going to worry about that for now.
Thanks for the idea about using a front script. This was a very weird combination of issues that caused all of this.
Thanks for the idea about using a front script. This was a very weird combination of issues that caused all of this.
Re: Using a mneonic of m
Your welcome, glad it worked out for you.
For the flashing mnemonic indicator, if you disable it long enough to invoke some code, you could also try the lockScreen method. Lock screen, disable mnemonic, invoke script, enable mnemonic, unlock screen. That might work unless you need a series of visual changes to take place immediately. But im guessing you have it disabled long enough for the script to take place. If so, it should work fine. You would see no flashing.
Good Luck!
For the flashing mnemonic indicator, if you disable it long enough to invoke some code, you could also try the lockScreen method. Lock screen, disable mnemonic, invoke script, enable mnemonic, unlock screen. That might work unless you need a series of visual changes to take place immediately. But im guessing you have it disabled long enough for the script to take place. If so, it should work fine. You would see no flashing.
Good Luck!
Chris Bodell
Photo Room - (Editor Download)
Photo Room - (Editor Download)