1. Win32Lib: Keypress Issue

Derek, anything wrong with this code? 'cuz it ain't workin'. (I've
thrown the win_FullScreen up for display from another window
(win_Main), and now I want to press ESC to make it go away.)

procedure win_FullScreen_onKeyPress (integer self, integer event, sequence
params)--params is ( int keyCode, int shift )
	if params[1] = VK_ESCAPE and fullScreenView then
		fullScreenView = w32False
		closeWindow( win_FullScreen )
	end if
end procedure
setHandler( Screen, w32HKeyPress, routine_id("win_FullScreen_onKeyPress"))

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » topic index » view message » categorize

2. Re: Win32Lib: Keypress Issue

cklester wrote:
> 
> Derek, anything wrong with this code? 'cuz it ain't workin'. (I've
> thrown the win_FullScreen up for display from another window
> (win_Main), and now I want to press ESC to make it go away.)
> 
> procedure win_FullScreen_onKeyPress (integer self, integer event, sequence
> params)--params
> is ( int keyCode, int shift )
> 	if params[1] = VK_ESCAPE and fullScreenView then
> 		fullScreenView = w32False
> 		closeWindow( win_FullScreen )
> 	end if
> end procedure
> setHandler( Screen, w32HKeyPress, routine_id("win_FullScreen_onKeyPress"))
> 

The code looks fine (and works here) so I guess the 'fullScreenView' is
not being set correctly or is being set to w32False somewhere else.



Here is the code I used to test it...

without warning
include win32lib.ew
integer fullScreenView fullScreenView = w32False

constant mw = create(Window, "Main", 0, 0, 0, 100, 100, 0)
constant win_FullScreen = create(Window, "FULL", 0, 200, 200, 400, 400, 0)


procedure win_FullScreen_onKeyPress (integer self, integer event, sequence
params)--params is ( int keyCode, int shift )
    if params[1] = VK_ESCAPE then
       if  fullScreenView = w32True then
            closeWindow( win_FullScreen )
       else
            openWindow(win_FullScreen, Normal)
       end if
    end if
end procedure
setHandler( Screen, w32HKeyPress, routine_id("win_FullScreen_onKeyPress"))

procedure win_FullScreen_onActivate (integer self, integer event, sequence
params)
    fullScreenView = w32True
end procedure
setHandler( win_FullScreen, w32HActivate,
routine_id("win_FullScreen_onActivate"))
    
procedure win_FullScreen_onClose(integer self, integer event, sequence params)
    fullScreenView = w32False
end procedure
setHandler( win_FullScreen, w32HClose, routine_id("win_FullScreen_onClose"))

openWindow(win_FullScreen, Normal)

WinMain(mw, Normal)


-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view message » categorize

3. Re: Win32Lib: Keypress Issue

Escape isn't a printable key, so onKeyPress doesn't catch it. Try
onKeyDown instead...

On Thu, 05 Aug 2004 21:46:08 -0700, cklester <guest at rapideuphoria.com> wrote:
> 
> posted by: cklester <cklester at yahoo.com>
> 
> Derek, anything wrong with this code? 'cuz it ain't workin'. (I've
> thrown the win_FullScreen up for display from another window
> (win_Main), and now I want to press ESC to make it go away.)
> 
> procedure win_FullScreen_onKeyPress (integer self, integer event, sequence
> params)--params is ( int keyCode, int shift )
>         if params[1] = VK_ESCAPE and fullScreenView then
>                 fullScreenView = w32False
>                 closeWindow( win_FullScreen )
>         end if
> end procedure
> setHandler( Screen, w32HKeyPress, routine_id("win_FullScreen_onKeyPress"))
> 
> -=ck
> "Programming in a state of EUPHORIA."
> http://www.cklester.com/euphoria/
> 
> 
> 
> 


-- 
MrTrick

new topic     » goto parent     » topic index » view message » categorize

4. Re: Win32Lib: Keypress Issue

Derek Parnell wrote:
> 
> cklester wrote:
> > 
> > Derek, anything wrong with this code? 'cuz it ain't workin'. (I've
> > thrown the win_FullScreen up for display from another window
> > (win_Main), and now I want to press ESC to make it go away.)
> > 
> > procedure win_FullScreen_onKeyPress (integer self, integer event, sequence
> > params)--params
> > is ( int keyCode, int shift )
> > 	if params[1] = VK_ESCAPE and fullScreenView then
> > 		fullScreenView = w32False
> > 		closeWindow( win_FullScreen )
> > 	end if
> > end procedure
> > setHandler( Screen, w32HKeyPress, routine_id("win_FullScreen_onKeyPress"))
> > 
> 
> The code looks fine (and works here) so I guess the 'fullScreenView' is
> not being set correctly or is being set to w32False somewhere else.

I verified that fullScreenView is being set properly. I even used this:

> > 	if params[1] = VK_ESCAPE and w32True then

but it still doesn't work!

> Here is the code I used to test it...

Your code works, of course... :/ :)

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

5. Re: Win32Lib: Keypress Issue

Patrick Barnes wrote:
> 
> Escape isn't a printable key, so onKeyPress doesn't catch it. Try
> onKeyDown instead...

Hey, Patrick,

Derek's example uses onKeyPress and works... grrrr.

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

6. Re: Win32Lib: Keypress Issue

Derek Parnell wrote:
> 
> cklester wrote:
> > 
> > Derek, anything wrong with this code? 'cuz it ain't workin'. (I've
> > thrown the win_FullScreen up for display from another window
> > (win_Main), and now I want to press ESC to make it go away.)
> > 
> The code looks fine (and works here) so I guess the 'fullScreenView' is
> not being set correctly or is being set to w32False somewhere else.

Maybe I should get the latest patch to Win32Lib? :)

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

7. Re: Win32Lib: Keypress Issue

Derek Parnell wrote:

> > procedure win_FullScreen_onKeyPress (integer self, integer event, sequence
> > params)--params
> > is ( int keyCode, int shift )
> > 	if params[1] = VK_ESCAPE and fullScreenView then
> > 		fullScreenView = w32False
> > 		closeWindow( win_FullScreen )
> > 	end if
> > end procedure
> > setHandler( Screen, w32HKeyPress, routine_id("win_FullScreen_onKeyPress"))

Derek, I was using showWindow() instead of openWindow(). Why does
that make a difference?

A menu click was setting fullScreenView to w32True, then
triggered showWindow() for the fullScreenView. Is that why
the Screen wasn't receiving my ESC press?

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

8. Re: Win32Lib: Keypress Issue

cklester wrote:
> 
> Derek Parnell wrote:
> 
> > > procedure win_FullScreen_onKeyPress (integer self, integer event, sequence
> > > params)--params
> > > is ( int keyCode, int shift )
> > > 	if params[1] = VK_ESCAPE and fullScreenView then
> > > 		fullScreenView = w32False
> > > 		closeWindow( win_FullScreen )
> > > 	end if
> > > end procedure
> > > setHandler( Screen, w32HKeyPress, routine_id("win_FullScreen_onKeyPress"))
> 
> Derek, I was using showWindow() instead of openWindow(). Why does
> that make a difference?

It doesn't, for this exercise. See example code below.
 
> A menu click was setting fullScreenView to w32True, then
> triggered showWindow() for the fullScreenView. Is that why
> the Screen wasn't receiving my ESC press?

Are you sure the menu click is actually firing?

without warning
include win32lib.ew
integer fullScreenView fullScreenView = w32False

constant mw = create(Window, "Main", 0, 0, 0, 100, 100, 0)
constant win_FullScreen = create(Window, "FULL", 0, 200, 200, 400, 400, 0)

procedure win_FullScreen_onKeyPress (integer self, integer event, sequence
params)
    if params[1] = VK_ESCAPE then
        fullScreenView = (not fullScreenView)
        showWindow( win_FullScreen, fullScreenView )
    end if
end procedure
setHandler( Screen, w32HKeyPress, routine_id("win_FullScreen_onKeyPress"))

WinMain(mw, Normal)


-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view message » categorize

9. Re: Win32Lib: Keypress Issue

Derek Parnell wrote:
> 
> > Derek, I was using showWindow() instead of openWindow(). Why does
> > that make a difference?
> 
> It doesn't, for this exercise. See example code below.
>  
> > A menu click was setting fullScreenView to w32True, then
> > triggered showWindow() for the fullScreenView. Is that why
> > the Screen wasn't receiving my ESC press?
> 
> Are you sure the menu click is actually firing?

Well, I figure the win_FullScreen wouldn't display unless the
menu item fired... because that's the only place it's called
to open.

Besides, IIRC, changing the showWindow() to openWindow() suddenly
caused it to start working. :)

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu