How to stop the scene while handling GUI events?

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
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

How to stop the scene while handling GUI events?

Post by wsw1231 »

Image

My program has an operating mode called MODE_ROTATE to rotate objects. This operating mode is triggered when the user presses 'r' key.

Now, the problem is, as you can see in the above picture, the user would like to save the scene and type the file name which is "ABC.irr" meaning that 'r' has been pressed and the operating mode is changed from nothing to MODE_ROTATE.

How to stop the event receiver when doing things in the GUI elements?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You can either switch to modes (i.e. when GUI is open don't set rotate) or check if a GUI element has focus and send the event there.
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

hybrid wrote:You can either switch to modes (i.e. when GUI is open don't set rotate) or check if a GUI element has focus and send the event there.
How can I check if the GUI element is focused?
Which API should be used?

guielement -> isEnabled()?
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

Also, another problem is that if I click on the GUI element, the object in the scene (at the back) will be selected.

How to solve that :(
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Same way, just other direction. Check if you would hit a gui element, then pass it there/ignore it in your event receiver. IIRC, there have been some examples no how to achieve that, try to search for them.
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

how to ignore the things in the background when the GUI element is focused?

Code: Select all

case EGET_ELEMENT_FOCUSED:
{
     //what to do?	
}break;
Also, if the element is focused, that means the user clicks the left mouse button on the element meaning that EMIE_LMOUSE_PRESSED_DOWN is also triggered.

How to handle this case in which EMIE_LMOUSE_PRESSED_DOWN and EGET_ELEMENT_FOCUSED happen at the same time?
CuteAlien
Admin
Posts: 9718
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

With env->getRootGUIElement()->getElementFromPoint
you can check which element is below the mouse. If it is anything but the RootGUIElement itself then you are probably over a gui-element and don't want to handle those mouse-events for 3D selection.
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
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

CuteAlien wrote:With env->getRootGUIElement()->getElementFromPoint
you can check which element is below the mouse. If it is anything but the RootGUIElement itself then you are probably over a gui-element and don't want to handle those mouse-events for 3D selection.
How to check if env->getRootGUIElement()->getElementFromPoint(mouse_click_pos); returns a gui element other than the root one? by ID?

Apart from mouse clicking problem, how to solve the changing mode problem?

Should I use

Code: Select all

case EGET_ELEMENT_FOCUSED: 
{

}
But how to prevent the event receiver from going into the following code?

Code: Select all

case EET_KEY_INPUT_EVENT :
{
}
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

1) Compare with getRootGUIElement()
2) Well, maybe, did you try already?
3) Use if(...)
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

sorry.....I still do not get it....
Could you please give me some sample code?

If I click on the GUI element (not root), it will be focused.

That means EGET_ELEMENT_FOCUSED will be checked.
But....by clicking the GUI element, that means EMIE_LMOUSE_PRESSED_DOWN will also be checked.

How to disable the checking of EMIE_LMOUSE_PRESSED_DOWN if EGET_ELEMENT_FOCUSED is being checked?

Any sample code?
CuteAlien
Admin
Posts: 9718
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

You don't suppress. Instead you have for example 2 states - GUI-state and Scene-state. Where you set that is up to you - only on clicks, or even on mouse-moves. And in all events where you don't want to act in one state you check for that. So if you don't want to the event to pass on in EMIE_LMOUSE_PRESSED_DOWN when you are in Scene-state you check for that and return true for that event (which means it won't be passed on any further).
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
Post Reply