What is difference between being window active and focused?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Andrey01
Posts: 57
Joined: Mon Jul 27, 2020 9:08 pm

What is difference between being window active and focused?

Post by Andrey01 »

I`ve noticed IrrlichtDevice class has two methods as isWindowActive() and isWindowFocused() from which the first checks whether the window is active, the second whether is focused. What is difference between "active" and "focused" modes of the window? Although, if an irrlicht device window is active currently, it means the current focus is that window in OS because all rendering and event catching occurs there. Does it not?
CuteAlien
Admin
Posts: 9646
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: What is difference between being window active and focus

Post by CuteAlien »

Focus is about keyboard input. There can be another sub-window which has the focus instead of the top-window. Note this is only abouts system windows - not related to Irrlicht GUI windows. And only for Win32 and SDL devices. On Linux it's a bit different implemented (it only checks focus and says it's active as long as the focused window is not minimized - no idea how sub-windows would be handled - maybe something no one ever tested).

In general you probably only care about isWindowActive unless you work with several system windows (stuff like using Irrlicht inside MFC and things like that).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Andrey01
Posts: 57
Joined: Mon Jul 27, 2020 9:08 pm

Re: What is difference between being window active and focus

Post by Andrey01 »

Thanks for reply. As I`ve understood you, the focus can have only the system windows as IrrlichtDevice, but the Irrlicht windows as gui::IGUIWindow can`t? And as you said, on Linux the focus can have all kinds of the windows unlike Windows OS, right? Then gui::IGUIEnvironment::hasFocus(gui::IGUIElement* element) works only on Linux because gui::IGUIWindow is a sub-class of gui::IGUIElement. Do I understand correctly?
CuteAlien
Admin
Posts: 9646
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: What is difference between being window active and focus

Post by CuteAlien »

Irrlicht GUI and the isWindowFocused are unrelated. isWindowFocused is about windows created by the operating system. It doesn't even know about any kind of drawings Irrlicht does (like drawing it's own UI).

This function doesn't matter if you just create an Irrlicht device and use it like that. But... some users do stuff like create system windows on top of Irrlicht. Or use Irrlicht inside their own window system (inside MFC, Qt or native Window applications - stuff like that). Thought even then it's a function you rarely need - I don't think I ever used it.

gui::IGUIEnvironment::hasFocus is about Irrlicht GUI - completely other topic. Only same name as all GUI systems have similar concepts and thereby use same names. It always works inside Irrlicht. But one of the pre-conditions for Irrlicht GUI working is that Irrlicht receives mouse and keyboard events in the first place. But unless you do special stuff you will get that already if isWindowActive is true.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Andrey01
Posts: 57
Joined: Mon Jul 27, 2020 9:08 pm

Re: What is difference between being window active and focus

Post by Andrey01 »

Ok, thanks for explanation.
Post Reply