[osg-users] Detecting windows focus

90 views
Skip to first unread message

Bram Vaessen

unread,
May 12, 2013, 2:54:29 PM5/12/13
to osg-...@lists.openscenegraph.org
Hi,

I've been looking for a while on the forum and using google, and looking in the documentation and the code, but i can't seem to find:

how can I detect if a window (osgViewer::GraphicsWindow) has lost focus? I see there is a function to GRAB focus, but isn't it possible to check whether or not the window HAS focus?

Thank you!

Cheers,
Bram

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=53990#53990





_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Robert Osfield

unread,
May 13, 2013, 3:18:47 AM5/13/13
to OpenSceneGraph Users
Hi Bram,


On 12 May 2013 19:54, Bram Vaessen <bram.v...@gmail.com> wrote:
I've been looking for a while on the forum and using google, and looking in the documentation and the code, but i can't seem to find:

how can I detect if a window (osgViewer::GraphicsWindow) has lost focus? I see there is a function to GRAB focus, but isn't it possible to check whether or not the window HAS focus?

There isn't any built in support for tracking when a window has lost focus.  I have never tried implementing code that tracks focus at a Windowing level so can't guide you with this, but it almost certainly will require some platform specific code, what it might be I have no clue.

Robert.

Bram Vaessen

unread,
May 13, 2013, 3:31:30 AM5/13/13
to osg-...@lists.openscenegraph.org
Ok, then at least I know that it's not in OSG then (might be a good idea to implement this?).

I did notice there is a win32 implementation of the GraphicsWindow, GraphicsWindowWin32 I think, which can give the windows-handle, so I could possibly look up some win32 api calls to check this. It's just during the debugging process only that I need this.

Thanks for the information!

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=53994#53994

Robert Osfield

unread,
May 13, 2013, 3:53:59 AM5/13/13
to OpenSceneGraph Users
On 13 May 2013 08:31, Bram Vaessen <bram.v...@gmail.com> wrote:
Ok, then at least I know that it's not in OSG then (might be a good idea to implement this?).

I don't recall other users looking for the feature, if they had it likely would have already been written and already be part of the OSG. The fact that it isn't tells me that it's a rather niche feature and the fact you only need it for debugging confirms this.

Robert.

Bram Vaessen

unread,
May 13, 2013, 5:00:27 PM5/13/13
to osg-...@lists.openscenegraph.org
It's really not that much of a niche. If you work with windowes graphics and poll mouse information it will continue to do so and react to it even if you are no longer working in the osg application. Most games that run in a window disable event pulling when the window is no longer active. But since its not possible to check whether the window is active in osg... You dont know when should stop handling mouse events.

As OSG mostly takes over all aspects of creating and handeling a windows, checking the focus should be part of it in my opinion, even if i'm the first one to publically ask.. It just makes it more complete.

It rather suprises me that no one has asked for it to be honest.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=54008#54008

Sergey Kurdakov

unread,
May 13, 2013, 6:08:54 PM5/13/13
to osg-...@lists.openscenegraph.org
Hi Bram,

one suggestion for 'hackish' way  to implement,

for windows in

osgViewer/GraphicsWindowWin32.cpp

in handleNativeWindowingEvent(

to add handling of boolean for focused state tracing events WM_SETFOCUS  WM_KILLFOCUS  WM_ACTIVATE like described in

http://stackoverflow.com/questions/466354/how-can-i-tell-if-a-window-has-focus-win32-api answer 4

and request the state when needed (either pushing in osg event Queue (getEventQueue (push) then checkEvents (get)) or by 'hackish' way )

or, if it is desired to have for many platforms and have official osg support - then there is need for patch for other platforms

Regards
Sergey

Bram Vaessen

unread,
May 14, 2013, 2:22:02 AM5/14/13
to osg-...@lists.openscenegraph.org
Thanks, i will have a look at it!

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=54010#54010
Reply all
Reply to author
Forward
0 new messages