Re: Key Press to have Window "reappear ??
- Posted by DerekParnell (admin) Feb 22, 2011
- 1652 views
Selgor said...
So, I would like to press a key e.g. ESCAPE to have the window strip "reappear".
The problem is that keys only respond to the control that has focus at the time of keypress, and a Window almost never has focus ... especially if its invisible.
The solution is to set a keystroke handler for the Screen control. This is a special control that is always defined, so you don't have to create it. It gets every message from Windows for your application.
So you only have to do a minor chnage to your program; change the handler for Win to Screen and things should be better.
-- The changed code would be ... procedure WinKey(integer self, integer event, sequence parms) -- Check for key presses. if parms[1] = VK_ESCAPE then setVisible(Win,1) elsif parms[1] = VK_ENTER then init_vars() end if end procedure setHandler( Screen , w32HKeyDown, routine_id("WinKey"))