Actually what you need is info("keycode")
to determine the correct numeric value. Unfortunately, this function doesn’t exist in Panorama X. I think I may implemented it tonight or tomorrow.
According to the definehotkeys documentation, you should be able to use this to add hot key code for the left arrow. Notice that it is “left”, not “leftarrow”.
definehotkeys "window","left",{message "left arrow pressed"}
However, that code doesn’t work. I did some experimentation, and this code does work.
definehotkeys "window","function-left",{message "left arrow pressed"}
For some reason, Apple is adding the function modifier when the arrow keys are pressed. Weird. And if you actually press the function key and an arrow key at the same time, it sends a completely different key code. I don’t know of any other key that works like that, and I’m pretty sure Carbon (which Panorama 6 uses) does not work that way.
So for right now, you can define the arrow hot key code using function-left
, function-right
, etc. Now that I know about this, however, I may add special case code to change this, however, so be warned that code you write today might have to be changed soon. I’ll keep you updated on what I decide.
I have another suggestion (optional), let’s look at the first line of your code:
if info("formevent") match "Front"
Panorama X 10.1 has a new way to do this. The old way will still work (and congrats on figuring it out w/o documentation), but the new method will have higher performance. To learn about this new way see Form Event Procedures on the Implicitly Triggered Procedures page.
So I would switch the code to:
return
formFRONT:
definehotkeys "window","function-left",{message "left arrow pressed"}
return
Also, I might think about changing formFRONT
to formOPEN
, no reason to run this code every time the window comes to the front. Though it is kind of handy for debugging. If you do leave it as formFRONT
, I would actually change it to this:
return
formFRONT:
deletehotkeys "window"
definehotkeys "window","function-left",{message "left arrow pressed"}
return
This makes sure that you have a “clean slate” every time you change the hot key definitions. If you use formOPEN
, this isn’t really necessary because you’ll get a clean slate every time the form opens anyway.
Let me take a moment to explain why this is no longer in Panorama X. The .KeyDown procedure was a very coarse tool – EVERY SINGLE KEY typed into the database would go thru the .KeyDown code. Usually you only want special handling for a few keys, and you want Panorama to handle the rest. This was cumbersome, slow and also required the key
statement, which was going to be difficult to implement under Cocoa.
With the new system, you can trap only the exact keys you want, and only in specific windows if you want. All other keys are automatically left to Panorama to handle (at full speed). So you just worry about the specific situations where you do want custom key handling