Button Press Problem

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
manik_sheeri
Posts: 53
Joined: Tue May 19, 2009 12:18 am

Button Press Problem

Post by manik_sheeri »

Hi,

I have aan application that is using touch screen.And I am using Irrlicht for the GUI development of my app. Now since I have to use only the touch screen (as a user interface), so I am simulating my touch events into mouse events and passing them to irrlicht device.

The touch screen driver generates the X and Y coodinate for me and I send these to my function and therefore to Irrlicht by the following way:


///////////////////
event.EventType = irr::EET_MOUSE_INPUT_EVENT;
event.MouseInput.X = x;
event.MouseInput.Y = y;

event.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN;
env->postEventFromUser(event);
event.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP;
env->postEventFromUser(event);
///////////////////

The problem is that I can not see the button being pressed.though the action associated with the press of the button is executed fine.

Any idea where I am wrong ?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Maybe it's because you never entered the button. You should try to call a mouse move event first.
manik_sheeri
Posts: 53
Joined: Tue May 19, 2009 12:18 am

Post by manik_sheeri »

I added the EMIE_MOUSE_MOVED event before the call to the two above mentioned events. But it is still not working.
Nox
Posts: 304
Joined: Wed Jan 14, 2009 6:23 pm

Post by Nox »

Well im not sure how irrlicht is getting the absolute position of a mouse by afaik this absolute position is used for the gui stuff.
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Re: Button Press Problem

Post by Nalin »

manik_sheeri wrote:event.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN;
env->postEventFromUser(event);
event.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP;
env->postEventFromUser(event);
///////////////////

The problem is that I can not see the button being pressed.though the action associated with the press of the button is executed fine.
IGUIButton will draw the pressed state when it receives EMIE_LMOUSE_PRESSED_DOWN. When it receives EMIE_LMOUSE_LEFT_UP, it executes the button and draws the normal state. If you are sending both of those events immediately after each other, the engine will never draw the pressed state as EMIE_LMOUSE_LEFT_UP will return the button to its normal state.

Either add a sufficient delay between the two events so at least one draw cycle happens, or change your touch screen code to only issue EMIE_LMOUSE_LEFT_UP when the user removes their finger.
manik_sheeri
Posts: 53
Joined: Tue May 19, 2009 12:18 am

Post by manik_sheeri »

Thanks Nalin. It is working fine now.Thanks a lot.
Post Reply