PDA

View Full Version : Use the keyboard to execute actions


DanceParty
12-11-2002, 10:25 AM
Is there a way to have a key stroke execute an action. I would like it when the user hits the esc key, the application will end.

yosik
12-13-2002, 06:21 AM
very easy.
any button (visible or not) has a hotkey feature. If you want just the hotkey, make the button (can be a hotspot) 1 pixel big so it cannot be seen.
Good luck
Yossi

kpsmith
12-13-2002, 07:41 AM
You can even move the hotspot outside of the page boundaries if you don't even one the 1pixel x 1 pixel element to be clickable. The Shorcut for the projecthotspot will still work.

DanceParty
12-13-2002, 07:53 AM
Great thanks for your help. I figured it out. I always wondered what that did. I have a problem though. I want to be able to hit escape and have the app quit. When I click in the shortcut box and hit escape, the properties window closes. Can esc be used as a shortcut?

kpsmith
12-13-2002, 01:38 PM
Yes but you will need to edit the XML .AM4 file in WordPad or a text editor.

Find your object in the code by searching for the object name and change the virtual key number to 27. This is the Decimal Virtual Key number that represents the Esc key.

Here is an example of a hotspot named "Hotspot1" that I changed the key to ESC:

<Name>Hotspot1</Name>
<VisibleAtDesignTime>1</VisibleAtDesignTime>
<VisibleAtRunTime>1</VisibleAtRunTime>
<Locked>0</Locked>
<LockSize>0</LockSize>
<ToolTip/>
<Cursor>1</Cursor>
<Coordinates>
<Top>259</Top>
<Bottom>309</Bottom>
<Left>358</Left>
<Right>458</Right>
</Coordinates>
<Hotkey>
<VirtualKey>27</VirtualKey>

For a list of the decimal representations of the virtual keys you can check out this site.

http://www.delphicollection.com/public/Articles/KeyCodes.shtml

Make sure you look at the decimal number and not the hexadecimal.