How do I determine whether the delete key was released during a keyboard up event?
I see documentation on all the modifier keys, and it’s obvious how to test for the normal printable characters, but how does one test for the delete key?
I’m now stumped as to how to detect a left/right arrow key press within one-column table view, so I can switch to another table view without the user’s fingers leaving the arrow keys.
Is it possible to compare a key event to an arrow key press? If so, what value do you use for the arrow keys?
Beyond that, is it possible to catch such an event in a table view that’s in a scroll view?
Hmm. That’s what I thought. Yet, the code below doesn’t respond to the arrow key, although delete and space work fine. I assumed I had the wrong ASCII values for the arrow keys, but apparently there’s some other problem. Have you any idea why the code below doesn’t work?
keyboard up theObject event theEvent
if the name of theObject is "secondTableView" then
if character of theEvent is equal to (ASCII character 8) then
deleteThisRow()
return
end if
if character of theEvent is equal to (ASCII character 28) then
display dialog "left arrow"
return
end if
if character of theEvent is equal to (ASCII character 32) then
goNuts()
return
end if
end if
end keyboard up
Thank you for your help,
-Joe
PS: Thank you also for the pointer to the code utility. BTW, I notice you originally mentioned key codes, but the documentation says those are device-dependent and suggests they are not to be used. Is the documentation wrong as usual, and all keyboards use the same codes?
Apparently they do not all use the same codes - Laptops are different than desktop keyboards in ways I don’t know.
Vis-a-vis your problem, however, have you tried just using “Left Arrow” in place of (ASCII character 28)? When I run Jon’s Commands’ “keys pressed” command (in his OSAXen), it just returns “Left Arrow”.
Another possibilty is that it requires the Unicode Character (though I don’t know how to use that) which is 2190 for a left arrow and 2192 for a right arrow.
You get to see them this way (which toggles the server)
tell application "System Events"
if exists process "CharPaletteServer" then
do shell script "killall CharPaletteServer"
else
tell application "CharPaletteServer" to activate
end if
end tell
Thanks for the help, Adam and Kel. It looks like I’ll have to try some other way to accomplish this, or just erase the feature from my list.
In the mean time, I’m dealing with random signal 11’s on launch of my app now. No reason that I can discern. Plus, my custom menu items become disabled after two uses, even though I have no code at all relating to disabling them in my app. Looks like I’d better head over to the 10.4.3 breakage section.
Just a follow-up for my post above regarding the random crashing.
I created a new project, re-created the UI elements in the nib, then copied my code, help files, icons, etc. over and made the necessary changes to the project settings. That seems to have fixed the random crashing problem. But, since it was random, I’ll just have to wait a few days to find out if it’s really fixed.