Error with gui..
-
RapchikProgrammer
- Posts: 279
- Joined: Fri Dec 24, 2004 6:37 pm
Error with gui..
Hey.. i am using irrlicht after a loooonnnggg time.. i am having this problem.. i have created a gui menu with file, edit, help and stuff.. and just below this is an editing area for the user now.. when i open the file menu and click on a button like exit.. it does get a gui event of the menu clicked but it also gets an event of mouse click hence drawing on the editing area.. the gui and the editing area are two different classes who receive onevent calls from a main class.. any idea how to solve this??
The way i solve this is using a isPointOverGUI() function which i've written so when my event receiver gets a mouse clicked event if first uses this function to check if the mouse is over any GUI element, if so it ignores the event as the event will no doubt be used by the GUI element the mouse is over, otherwise it processes the event.
This happens because events are sent to the user before being sent to the GUI.
Here's my function i use:
This happens because events are sent to the user before being sent to the GUI.
Here's my function i use:
Code: Select all
bool MyEventReceiver::isPointOverGUIElement(const core::position2di& pos, IGUIElement* e) {
if (e->getElementFromPoint(pos) != NULL) return true;
core::list<IGUIElement*> children = e->getChildren();
core::list<IGUIElement*>::Iterator iter = children.begin();
while (iter != children.end()) {
if (e->getElementFromPoint(pos)) return true;
iter++;
}
return false;
}
bool MyEventReceiver::isPointOverGUI(const core::position2di& pos) {
IGUIElement* root = device->getGUIEnvironment()->getRootGUIElement();
core::list<IGUIElement*> children = root->getChildren();
core::list<IGUIElement*>::Iterator iter = children.begin();
while (iter != children.end()) {
if (isPointOverGUIElement(pos, *iter)) return true;
iter++;
}
return false;
}
-
RapchikProgrammer
- Posts: 279
- Joined: Fri Dec 24, 2004 6:37 pm
thanx a lot jp.. i forgot how good feedback was at the irrlicht forums.. the only problem with this code is that it doesnt handle sub menus.. like edit->colour->red, green, blue.. it works till edit->colour menu but when i click on the red, green or blue submenu it draws again.. its fine for now though.. thanks a lot..
