Can GUI events override Mouse/Keyboard 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
fernando24691
Posts: 10
Joined: Thu Jan 22, 2009 8:12 pm

Can GUI events override Mouse/Keyboard events?

Post by fernando24691 »

Hello everybody!

At last I've coded my event receiver. I've enabled it to handle GUI, mouse and keyboard events. But there's a little problem.

First of all say that I coded a function that moves the player everywhere I click in the 3d world (a classic "goTo" function). Well, when I click a button , it runs ok, but the goTo function also starts, and makes the player go to the point "behind" the button in 3d world.

To solve this, I need to override GUI events over mouse events, so I can click the button without moving th player. So, any idea? :oops:

Thanks!
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

as you know from the other post a return true; causes Irrlicht to not handle the event enymore...
so after you handled the button click event return true, that should do it... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
fernando24691
Posts: 10
Joined: Thu Jan 22, 2009 8:12 pm

Post by fernando24691 »

You saved me two times dude ..... :wink:
fernando24691
Posts: 10
Joined: Thu Jan 22, 2009 8:12 pm

Post by fernando24691 »

I think I missunderstood you ... :oops: .... I cannot solve it...

Here's my receiver structure:

Code: Select all


virtual bool OnEvent(const SEvent& event)
   {
       if (event.EventType == EET_KEY_INPUT_EVENT)
              {
             ///BLABLABLABLABLA
               }


       if (event.EventType == EET_MOUSE_INPUT_EVENT)
               {
             ///BLABLABLABLABLA
               }


        if (event.EventType == EET_GUI_EVENT)
               {
             ///BLABLABLABLABLA
               }

      return false;
     }
As you said me, If I return true, GUI code doesn't run, only mouse and keys, so, as you can see, I returned false.

Now, as you said, I guess I had to return true after GUI event code... so my receiver would be:

Code: Select all


virtual bool OnEvent(const SEvent& event)
   {
       if (event.EventType == EET_KEY_INPUT_EVENT)
              {
             ///BLABLABLABLABLA
               }


       if (event.EventType == EET_MOUSE_INPUT_EVENT)
               {
             ///BLABLABLABLABLA
               }


        if (event.EventType == EET_GUI_EVENT)
               {
             ///BLABLABLABLABLA
             return true;
               }

      return false;
     }
But that doesn't change the behaviour of the program. I still having mouse and GUI events at once. What's wrong? :roll:
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

ohh, yes, sorry, that's because a gui event always has a mouse event first... :oops:

maybe this thread can help you: http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=30463
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
fernando24691
Posts: 10
Joined: Thu Jan 22, 2009 8:12 pm

Post by fernando24691 »

That post definitely solved my problem! :wink: Thanks
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

Indeed. I had this problem for my simulator. Lots of headache, but I fixed it on my own. It's the way that I ordered them and had to take out some "return false;" 's
Josiah Hartzell
Image
Post Reply