Idiot question here, but does anyone (Vern? Or maybe Wes now :>) know what value I need to insert here?
if (keyEvent.key == "J") then
Because "J" doesn't work, nor does 'J'. If it's a literal (like "KEY.J") I don't know how to find it so I'd just be guessing.
As for the larger picture, I'm trying to disable the spacebar that welds when translate points is the selected tool (because then I can't use the spacebar for playback with my macros). In *that* code this works:
if (keyEvent.key == ' ') then
which led me to believe my own syntax was correct (which is to say, there ain't no string literal being used there, such as KEY.SPACEBAR).
(Oh, do I hate syntax -- hate taxes in general, but this kind of tax is just ridiculous <bg>)
Keyevent value?
Moderators: Víctor Paredes, Belgarath, slowtiger
- synthsin75
- Posts: 10280
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
If I'm not mistaken, that should read:
I think spacebar is considered a special character, so it is refernced that way instead.

Code: Select all
if (keyEvent(J) == true) then

Ah, I guess I really don't know what I'm doing here.
Not sure whether your syntax works or not, but one thing is for sure -- I can't seem to disable the spacebar thingee no matter what I try. More confusing, I can't seem to change the bottom text (where it says "Move Selected Points") which at first glance would seem to indicate that I'm not editing the right tool, but if I remove LM_Translate_Points then translation won't work. But any editing to it seems to be completely ignored.
If you get a chance, Wes, perhaps you could try it. Edit line 24 (where the text is) and see if you can get it to change along the bottom when the (T) tool is selected (on a vector layer). Otherwise I might just not have gotten enough sleep last night.
Not sure whether your syntax works or not, but one thing is for sure -- I can't seem to disable the spacebar thingee no matter what I try. More confusing, I can't seem to change the bottom text (where it says "Move Selected Points") which at first glance would seem to indicate that I'm not editing the right tool, but if I remove LM_Translate_Points then translation won't work. But any editing to it seems to be completely ignored.
If you get a chance, Wes, perhaps you could try it. Edit line 24 (where the text is) and see if you can get it to change along the bottom when the (T) tool is selected (on a vector layer). Otherwise I might just not have gotten enough sleep last night.
This won't work.
Use this:
The keyEvent.key is the character that was pressed. You then use that local var "theKey" to compare to the actual key you want pressed to cause something to happen.
or:
EDIT:
Don't forget that keyEvent.key is a "string" even if you press a number. If you want a "real" number when pressing 0-9 then use:
There are some key commands you absolutely can't change or "over ride" in any way using scripting with some of the tools. These keys are "built in" to the application. You can use them for tools but they will still do what they originally did.
I don't know if the space bar is one of those but it might be. I found this mainly with some of the "fkey" commands. Couldn't "deactivate" them.
-vern
Code: Select all
if (keyEvent(J) == true) then
Code: Select all
local theKey = keyEvent.key
Code: Select all
if (theKey == "J") then
.... do stuff
end
Code: Select all
if (keyEvent.key == "J") then
.... do stuff
end
Don't forget that keyEvent.key is a "string" even if you press a number. If you want a "real" number when pressing 0-9 then use:
Code: Select all
tonumber(keyEvent.key)
I don't know if the space bar is one of those but it might be. I found this mainly with some of the "fkey" commands. Couldn't "deactivate" them.
-vern
Additional:
Will give you the "ascii" number of the key pressed.
"j" for instance (at least on the mac) returns "106". I am pretty sure they are same regardless of OS but not positive.
-vern
Code: Select all
keyEvent.keyCode
"j" for instance (at least on the mac) returns "106". I am pretty sure they are same regardless of OS but not positive.
-vern
- synthsin75
- Posts: 10280
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
That is because LM's tools reference the 'strings' file for this info. If you kill the previous LM_TranslatePoints.BASE_STR = 2375, then you should be able to change that text.More confusing, I can't seem to change the bottom text (where it says "Move Selected Points") which at first glance would seem to indicate that I'm not editing the right tool
