how to avoid triggering many click event when I click once.
-
- Posts: 2
- Joined: Sat Jul 23, 2011 2:17 pm
how to avoid triggering many click event when I click once.
I have created a event listener for left mouse button. However, when I click once, the event has been triggered many times.Any idea of how to avoid this problem?
Re: how to avoid triggering many click event when I click o
use a flag that indicates if the button is down or up...
and then, if the button is down and was previously up act on it, otherwise don't...
and then, if the button is down and was previously up act on it, otherwise don't...
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
- Posts: 288
- Joined: Wed Apr 16, 2008 1:45 am
- Contact:
Re: how to avoid triggering many click event when I click o
If you haven't already read the tutorials please do so,
http://irrlicht.sourceforge.net/docu/example019.html
Is for the mouse control such as a click and should be able to guide you on how to do it. If you already have then I would suggest altering your code to make it only return that the mouse is down once and then have to wait for the mouse to go up before it sends another down... Basically a flag as Acki stated but posted before I could...
http://irrlicht.sourceforge.net/docu/example019.html
Is for the mouse control such as a click and should be able to guide you on how to do it. If you already have then I would suggest altering your code to make it only return that the mouse is down once and then have to wait for the mouse to go up before it sends another down... Basically a flag as Acki stated but posted before I could...
Re: how to avoid triggering many click event when I click o
Also, just in case, are you using "event.MouseInput.isLeftPressed () == true;" ? instead of
because, in the first case, "isLeftPressed ()" will return true over and over again every frame until the mouse button is lifted up again, which, in the bullet-time of the computer could be several frames before your slow human finger can let go of the LMouse_button and trigger the event which sets "isLeftPress()" to false.
If that's not the case, then go with what Acki and Insomniacp said.
Code: Select all
switch (event)
{
case: (EventType == EET_MOUSE_INPUT_EVENT)
{
if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
// do your stuff here
...
break;
};
case: (EventType == EET_Some_other_event_type)
{
// do other stuff
...
};
};
If that's not the case, then go with what Acki and Insomniacp said.
"Computers don't make mistakes! What they do they do on purpose!!"
-Dale Gribble
-Dale Gribble