Clicking behind AddMessageBox window
Clicking behind AddMessageBox window
Hi,
I have an app, if you click anywhere in the room, a message box appears. (easiest description)
When I click on the OK button (1.) on the message box, the message box closes, but the click event is accepted by the main loop, so the message box appears once again. Like an infinite loop...
But if I click on the close button of the message window (2.), the message box closes, and does not appears again!
Also, if I push the ENTER button, the messagebox closes, and since there was no click (I pushed the ENTER button), the message box does not appears.
This would also my behaviour, if I click on the OK button. What is the difference? What kind of event should I handle to prevent this?
I have an app, if you click anywhere in the room, a message box appears. (easiest description)
When I click on the OK button (1.) on the message box, the message box closes, but the click event is accepted by the main loop, so the message box appears once again. Like an infinite loop...
But if I click on the close button of the message window (2.), the message box closes, and does not appears again!
Also, if I push the ENTER button, the messagebox closes, and since there was no click (I pushed the ENTER button), the message box does not appears.
This would also my behaviour, if I click on the OK button. What is the difference? What kind of event should I handle to prevent this?
Re: Clicking behind AddMessageBox window
On which event do you show the messagebox? Left-Mouse-Down or Left-Mouse-Up? Just asking as I have to write some code to reproduce this first before I can tell anything...
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Clicking behind AddMessageBox window
This is the main loop:
Code: Select all
while(device->run())
{
driver->beginScene(true, true, SColor(0,200,200,200));
smgr->drawAll();
env->drawAll();
// other code, not relevant here
if ( _found ) // clicking inside the room. if the room's ID (ID of the mesh) equals to some integer, _found = 1
{
env->addMessageBox( L"Congratulations!" , L"You found the correct room!" , true , EMBF_OK , 0 , 404 , 0 );
if ( admin.camera )
admin.camera->setInputReceiverEnabled ( !admin.camera->isInputReceiverEnabled() );
}
}
Re: Clicking behind AddMessageBox window
Sorry, that doesn't help me. I still need to know which event you check (probably you set _found in it?).
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Clicking behind AddMessageBox window
hi,
Sorry, I will try to push more code now... So if the user clicks on an octree mesh (receiver.Selected->getID()) , and this ID is equals to some value, than I would like to show a messagebox.
Sorry, I will try to push more code now... So if the user clicks on an octree mesh (receiver.Selected->getID()) , and this ID is equals to some value, than I would like to show a messagebox.
Code: Select all
MyEventReceiver receiver(smgr);
device->setEventReceiver(&receiver);
while(device->run())
{
driver->beginScene(true, true, SColor(0,200,200,200));
smgr->drawAll();
env->drawAll();
// other code, not relevant here
if (receiver.Selected)
{
s32 id;
id = receiver.Selected->getID();
int _found = 0;
if ( id == 2000 )
{
// do something
_found = 1;
}
if ( _found ) // clicking inside the room. if the room's ID (ID of the mesh) equals to some integer, _found = 1
{
env->addMessageBox( L"Congratulations!" , L"You found the correct room!" , true , EMBF_OK , 0 , 404 , 0 );
if ( admin.camera )
admin.camera->setInputReceiverEnabled ( !admin.camera->isInputReceiverEnabled() );
}
}
Re: Clicking behind AddMessageBox window
*sigh* we got our wires crossed it seems. I need to know the event on which you react. It should be either Left-Mouse-Down or Left-Mouse-Up... I can't write a test to check if an event is not catched unless I know _which_ event you are catching. So from your new code I guess - somewhere around where you set receiver.Selected.
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Clicking behind AddMessageBox window
ibax,
in my old project http://sourceforge.net/projects/solarmodel
i did next:
- added global var: bool dialog_visible = false;
- each time i do addMessageBox(), i do dialog_visible = true;
- when you handle OK or CANCEL (your custom buttons) you need to do dialog_visible = false;
- to handle "X" button, you need to handle event like:
P.S.: of cause, before you want do addMessageBox(), you need to check if dialog_visible is false.
in my old project http://sourceforge.net/projects/solarmodel
i did next:
- added global var: bool dialog_visible = false;
- each time i do addMessageBox(), i do dialog_visible = true;
- when you handle OK or CANCEL (your custom buttons) you need to do dialog_visible = false;
- to handle "X" button, you need to handle event like:
Code: Select all
if (event.EventType == EET_GUI_EVENT && event.GUIEvent.EventType == EGET_MESSAGEBOX_CANCEL)
{
//...
dialog_visible = false;
}
Re: Clicking behind AddMessageBox window
hi,
my event for which I react is the following:
So I'm pressing the left mouse button, I select an octree, which has an ID. I'm checking this ID, and if the selected ID is the one I was searching for, message box appears with the successful text.
And here is the code for clicking on the YES of buttonId = 404
What I try to achieve is to close only the message box, and do not make an octree selection behind the messagebox. Because currently this is happenning. If there is an octree behind the messagebox, after clicking on the OK button of the messagebox, the messagebox closes, but the clicking is also accepted by the eventmanager, so an another messagebox appears again... that happens like an infinite loop.
my event for which I react is the following:
Code: Select all
if (event.EventType == EET_MOUSE_INPUT_EVENT && event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
{
core::position2di pos(event.MouseInput.X, event.MouseInput.Y);
core::line3d<f32> ray;
ray.start = admin.camera->getPosition();
ray.end = ray.start + (admin.camera->getTarget() - ray.start).normalize() * 1000.0f;
core::line3d<f32> line;
line.start = camera->getPosition();
line.end = line.start + (camera->getTarget() - line.start).normalize() * 1000.0f;
// Tracks the current intersection point with the level or a mesh
core::vector3df intersection;
// Used to show which triangle has been hit
core::triangle3df hitTriangle;
Selected = SceneManager->getSceneCollisionManager()->getSceneNodeAndCollisionPointFromRay(ray,intersection,hitTriangle,0,0,false);
}
Code: Select all
MyEventReceiver receiver(smgr);
device->setEventReceiver(&receiver);
while(device->run())
{
driver->beginScene(true, true, SColor(0,200,200,200));
smgr->drawAll();
env->drawAll();
// other code, not relevant here
if (receiver.Selected && windowIsOnTheScreen == false )
{
s32 id;
id = receiver.Selected->getID();
int _found = 0;
if ( id == 2000 )
{
// do something
_found = 1;
}
if ( _found ) // clicking inside the room. if the room's ID (ID of the mesh) equals to some integer, _found = 1
{
env->addMessageBox( L"Congratulations!" , L"You found the correct room!" , true , EMBF_OK , 0 , 404 , 0 );
if ( admin.camera )
admin.camera->setInputReceiverEnabled ( !admin.camera->isInputReceiverEnabled() );
windowIsOnTheScreen = true;
}
}
And here is the code for clicking on the YES of buttonId = 404
Code: Select all
case EGET_MESSAGEBOX_OK:
if ( id == 404 )
{
if ( admin.camera )
admin.camera->setInputReceiverEnabled ( !admin.camera->isInputReceiverEnabled() );
windowIsOnTheScreen = false;
break;
}
What I try to achieve is to close only the message box, and do not make an octree selection behind the messagebox. Because currently this is happenning. If there is an octree behind the messagebox, after clicking on the OK button of the messagebox, the messagebox closes, but the clicking is also accepted by the eventmanager, so an another messagebox appears again... that happens like an infinite loop.
Re: Clicking behind AddMessageBox window
Thx, that's the info I needed. I hope I find time soon to check what's going on.
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
Re: Clicking behind AddMessageBox window
Hi, Already got that problem. And there is a simple solution that you could use in your code when your are detecting the mouseclick, is to check if a GUI is present at the mouse position when you click.
Something like this:
It should return you GUIElement if there is a GUI at the specified position. Check the API for the details.
So if you check for this before doing the other stuff you should be able to get the click only when there is NO gui under the mouse when you click.
Something like this:
Code: Select all
guienv->getRootGUIElement()->getElementFromPoint()
So if you check for this before doing the other stuff you should be able to get the click only when there is NO gui under the mouse when you click.
Re: Clicking behind AddMessageBox window
Yeah, such a workaround will likely work. But I hope I find time to take a look what's going on. It should behave the same on all close buttons (on a quick look in code I thought it would do that, which is why I have to code a quick test first).
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
Re: Clicking behind AddMessageBox window
Hi, Thanks for checking this CuteAlien! I've got this on the requester, and also on other guis. One that I had the more problems with was the combobox. When I was selecting an item, I was receiving 2 events: a mouseclick event, then the itemchanged event. The code in the combobox GUI seem ok, but it use the LISTBOX gui that I've not checked yet.
Each time I was selecting an item in the combobox, it was doing a click under it. I found a workaround, that by checking the currently FOCUSED gui and checking if the parent id match a combobox would allow me to skip the mouseclick. (When you select an item in a combo box, the focus will switch to the children that is a listbox).
By doing this test, I think the mouseclick event come from the listbox gui. NOTE: The event that trigger from me is the mouse down event.
Each time I was selecting an item in the combobox, it was doing a click under it. I found a workaround, that by checking the currently FOCUSED gui and checking if the parent id match a combobox would allow me to skip the mouseclick. (When you select an item in a combo box, the focus will switch to the children that is a listbox).
By doing this test, I think the mouseclick event come from the listbox gui. NOTE: The event that trigger from me is the mouse down event.
Re: Clicking behind AddMessageBox window
Hi,
Currently I inserted a global variable, which was the idea of greenya. It seems that this workaround is working...
Of course, I'm still waiting for the answer of CuteAlien, since this is only a workaround, and maybe he will find out the reason of this behaviour I reported...
ibax
Currently I inserted a global variable, which was the idea of greenya. It seems that this workaround is working...
Of course, I'm still waiting for the answer of CuteAlien, since this is only a workaround, and maybe he will find out the reason of this behaviour I reported...
ibax
Re: Clicking behind AddMessageBox window
Sorry, not finding a difference - EMIE_LMOUSE_PRESSED_DOWN seems to always go through. My guess is that the reason it behaves different in your case is simply because those buttons are in different places - so the stuff hit behind them is not the same. And maybe the thing behind the close button is not ID == 2000?
The way to avoid is either to check what is below the mouse-cursor at that time and disregard it if it's certain gui-elements - maybe using the current hovered element is already enough in your case. Or just ignore it always when that dialog is visible.
The way to avoid is either to check what is below the mouse-cursor at that time and disregard it if it's certain gui-elements - maybe using the current hovered element is already enough in your case. Or just ignore it always when that dialog is visible.
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm