On Win32 it is possible to check the current key state with a call to
GetAsyncKeyState and I  am sure there is something similar on Linux.

As for fixing this in an osg application one idea for Win32 could be
to add a WM_ACTIVATE handler in
GraphicWindowWin32::handleNativeWindowingEvent. Note that this method
is virtual so the message can be handled by just deriving a class from
GraphicWindowWin32 so you do not have to modify any code inside the
osg library for this fix.
When the application get focus some calls to GetAsyncKeyState can be
made to check the status of the modifier keys and calls can be made to
EventQueue::keyPress/keyRelease to update the osg modifier key mask
accordingly. If you need to keep track of other keys that might have
been released or pressed when your application did not have focus you
have to call GetAsyncKeyState for them as well.

A conclusion to all this will anyhow be that if your Win32 application
is just interested in knowing if a key is pressed or not it is more
easy to call GetAsyncKeyState directly instead of keeping track of
keydown and keyup events.

/Jakob Ruhe

2008/6/18 Jean-Sébastien Guay <[EMAIL PROTECTED]>:
> Hello all,
>
>> To reproduce start the osgkeyboard example, press a few modifier
>> keys (let's say Ctrl and Shift) and while keeping them pressed
>> switch the desktop (e.g. on KDE) or minimize the window. Release
>> the modifier keys. Now, when you switch back or open the minimized
>> window, you'll see Ctrl and Shift still activated. And it's not
>> only an visual problem. These keys are actually not released, and
>> pressing 'a' will now really be seen as 'A'. That's very annoying
>> in FlightGear. One has to press and release the respective modifier
>> keys to get the missing release event.
>
> This also happens on Win32 (SVN version)... For example, press Alt+tab to
> switch to another window, and then go back to the osgkeyboard window, and
> you'll see that the alt key is "stuck".
>
> Does anyone have a fix? I'd work on it, but it's relatively low on my
> priority list, but it's annoying.
>
> J-S
> --
> ______________________________________________________
> Jean-Sebastien Guay    [EMAIL PROTECTED]
>                               http://www.cm-labs.com/
>                        http://whitestar02.webhop.org/
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to