Re: [osg-users] keyboard events not processed after osgviewer lose focus and get it back

2015-04-05 Thread Robert Osfield
Hi Nick,

This behaviour is probably down to the window manager requiring a click to
focus by default.  I don't recall a setting off the top of my head for
controlling this.

Robert.

On 5 April 2015 at 04:18, Trajce Nikolov NICK  wrote:

> Hi Community,
>
> In my cross-platform app I have processing of keybard input - simple
> terminal for writing commands in real-time. This is same on Windows and
> Linux (haven't tested it yet on Mac), but on Windows for example, you do
> Alt-TAB to get some other window and get it back again, the keyboard events
> are not processed anymore :-/. Seams like when osgViewer loses the focus it
> is not gaining it back from the system call. On windows I managed to do
> this - ( my background is Windows, on Linux I am new :-) ). Here is the
> snippet how I managed it to work on Windows. Anyone to share a snippet for
> Linux/Mac? As always, thanks a lot
>
> 
> while (!viewer->done())
> {
> #if defined(_WIN32)
> MSG msg;
> if (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
> {
> ::GetMessage(&msg, NULL, 0, 0);
> osgViewer::CompositeViewer::Windows wins;
> viewer->getWindows(wins);
>
> if (wins.size())
> {
> osgViewer::GraphicsHandleWin32 *hdl =
> dynamic_cast(wins.at(0));
> if(hdl)
> {
> WNDPROC fWndProc =
> (WNDPROC)::GetWindowLongPtr(hdl->getHWND(), GWLP_WNDPROC);
> fWndProc(hdl->getHWND(), msg.message, msg.wParam,
> msg.lParam);
> }
> }
> }
> #endif
> ..
> 
>
> Nick
>
> --
> trajce nikolov nick
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] keyboard events not processed after osgviewer lose focus and get it back

2015-04-04 Thread Trajce Nikolov NICK
Hi Community,

In my cross-platform app I have processing of keybard input - simple
terminal for writing commands in real-time. This is same on Windows and
Linux (haven't tested it yet on Mac), but on Windows for example, you do
Alt-TAB to get some other window and get it back again, the keyboard events
are not processed anymore :-/. Seams like when osgViewer loses the focus it
is not gaining it back from the system call. On windows I managed to do
this - ( my background is Windows, on Linux I am new :-) ). Here is the
snippet how I managed it to work on Windows. Anyone to share a snippet for
Linux/Mac? As always, thanks a lot


while (!viewer->done())
{
#if defined(_WIN32)
MSG msg;
if (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
{
::GetMessage(&msg, NULL, 0, 0);
osgViewer::CompositeViewer::Windows wins;
viewer->getWindows(wins);

if (wins.size())
{
osgViewer::GraphicsHandleWin32 *hdl =
dynamic_cast(wins.at(0));
if(hdl)
{
WNDPROC fWndProc =
(WNDPROC)::GetWindowLongPtr(hdl->getHWND(), GWLP_WNDPROC);
fWndProc(hdl->getHWND(), msg.message, msg.wParam,
msg.lParam);
}
}
}
#endif
..


Nick

-- 
trajce nikolov nick
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org