No event for gain/lose window focus

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
atomice

No event for gain/lose window focus

Post by atomice »

When Irrlicht is running in windowed mode and something has 'captured' the mouse (e.g. CCameraFPSSceneNode) then the mouse is still captured even when the user switches focus to another window (which means they can't use the mouse to control their other windows).
The only way to 'release' the mouse is to exit the running application.
There is currently no way of telling when the user switches to another window.
It would be useful to have some of kind of window focus gained/lost event which could be used to enable or disable mouse capture in an application. This would probably go in the loop that handles events from the operating system in CIrrDevice*.cpp.

(This is a duplicate of
http://sourceforge.net/tracker/index.ph ... tid=540679)
thesmileman
Posts: 360
Joined: Tue Feb 10, 2004 2:20 am
Location: Lubbock, TX

Post by thesmileman »

I don't think this is really a bug. But it would definitally be useful. I wonder if it would be difficult as irrlicht tries to support many different platforms such as windows and linux and their window handling is different.
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

It is not diffucult to achieve this. Just change your drawing loop from

Code: Select all

while(device->run()) 
{
}
to

Code: Select all

while(device->run()) 
if (device->isWindowActive())
{
}
Tels
Posts: 65
Joined: Fri Feb 27, 2004 7:56 pm
Location: Antarctica
Contact:

Post by Tels »

niko wrote:It is not diffucult to achieve this. Just change your drawing loop from

Code: Select all

while(device->run()) 
{
}
to

Code: Select all

while(device->run()) 
if (device->isWindowActive())
{
}
An event would be much more favourable. Irrlicht is event based, so the solution above is clunky, (one call overhead per frame, one if() with jump per frame!) and also non-obvious. I would much prefer to get an event. :!:

Best wishes,

Tels
Perl + Irrlicht + Audiere = Game: http://bloodgate.com/perl/game
Guest

Post by Guest »

While I agree an event would still be useful, thanks for showing me how to do this with the existing API Niko.
Post Reply