Hi,
I have a problem with making my game map editor.
I create a toolbox like in the meshviewer example.
I use the getSceneNodeFromScreenCoordinatesBB to find the position of my objects in the map.
My problem is that when I click on the toolbox, in the same time I find the position of the object behind it ... and I do want to...
For example, I selelect 2 waypoints, and then I click on the buton CONNECT in the toolbox => that doesn't work because in the same time it selects the object behind the toolbox ...
Can you help me please ???
GUIEvent and node from screen coordinates
It sounds like you are handling the mouse input from the user event receiver.
If you are doing this, then you need to return true from your OnEvent function when you handle the mouse click. If you don't handle the mouse click then the GUI will get a chance to handle it.
If you want to give priority to the GUI system, then you need to forward events to the GUI before you attempt to process them. If the GUI handles the event, then you should not.
Travis
If you are doing this, then you need to return true from your OnEvent function when you handle the mouse click. If you don't handle the mouse click then the GUI will get a chance to handle it.
If you want to give priority to the GUI system, then you need to forward events to the GUI before you attempt to process them. If the GUI handles the event, then you should not.
Code: Select all
bool MyEventReceiver::OnEvent(const SEvent& event)
{
if (Environment->postEventFromUser(event))
return true;
// do normal processing
}
Sorry to resurrect this topic, but if I'm having problems with this solution. If I use it, it crashes if any GUI events are posted, even if I simply mouse over the GUI. Is there any specific way I need to set up my event class to make this work?vitek wrote:It sounds like you are handling the mouse input from the user event receiver.
If you are doing this, then you need to return true from your OnEvent function when you handle the mouse click. If you don't handle the mouse click then the GUI will get a chance to handle it.
If you want to give priority to the GUI system, then you need to forward events to the GUI before you attempt to process them. If the GUI handles the event, then you should not.
TravisCode: Select all
bool MyEventReceiver::OnEvent(const SEvent& event) { if (Environment->postEventFromUser(event)) return true; // do normal processing }
I'll bet you're getting a stack overflow... If the gui doesn't handle an event, it passes the event to the user event receiver. The user event receiver passes the event to the gui, and so on.
You have to find a way to break the cycle. It is pretty easy to do...
Unfortunately the code written is just an easy out, and it turns into a bit of a hack. A better solution is to only handle user input in your event receiver if there is no gui to handle the events. This can be done with some state management system, but that is a little complicated to write up in a forum post.
Travis
You have to find a way to break the cycle. It is pretty easy to do...
Code: Select all
class MyEventReceiver : public IEventReceiver
{
private:
SEvent* Event;
};
MyEventReceiver::MyEventReceiver()
: Event(0)
{
}
bool MyEventReceiver::OnEvent(const SEvent& event)
{
// recursion prevention
if (&event == Event)
return false;
SEvent* save = Event;
Event = &event
if (Environment->postEventFromUser(event))
return true;
// do normal processing
Event = save;
return false;
}
Unfortunately the code written is just an easy out, and it turns into a bit of a hack. A better solution is to only handle user input in your event receiver if there is no gui to handle the events. This can be done with some state management system, but that is a little complicated to write up in a forum post.
Travis
Yeah, I know what you mean. I had the GUI working like that originally. The menu was opened and closed with the Escape key, and the mouse input events were disabled while the menu was up. It worked just fine, but now I'm at a point where that is too limited for what I want to do.vitek wrote: This can be done with some state management system, but that is a little complicated to write up in a forum post.
I appreciate the response, though, and I will give it a shot if there are absolutely no nicer ways of doing it.
But are there really no "clean" ways to check GUI events first, and completely skip everything if it is a GUI event? Or at least a way to suppress mouse events if they're generated at the same time as a GUI event? Something like this (though it doesn't work):
Code: Select all
if (Event.EventType == EET_GUI_EVENT)
{
blah blah
return true;
}
if (Event.EventType == EET_MOUSE_INPUT_EVENT)
{
blah blah
return true;
}
return false;
-
- Posts: 17
- Joined: Tue Dec 05, 2006 5:07 pm
-
- Posts: 17
- Joined: Tue Dec 05, 2006 5:07 pm
Would this other chunk of code provided by vitek (again!) be an appropriate solution, giving precedence to the GUI over other event receivers?
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=11785
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=11785