How to Emit a button pressed event

In Neutrino TRP ,I use following function to Emit a button pressed
event:

void function(int xcoord,int ycoord)
{
PhEvent_t event;
PhRect_t rect;
PhPointerEvent_t ptr_event;
iov_t mx[4];

event.type = Ph_EV_BUT_PRESS;
event.subtype = 0;
event.emitter.rid = Ph_DEV_RID;
event.flags = 0;
event.num_rects = 1;
event.data_len = sizeof( ptr_event );

rect.ul.x = rect.lr.x = xcoord;
rect.ul.x = rect.lr.y = ycoord;

ptr_event.flags = 0;
ptr_event.buttons = Ph_BUTTON_SELECT;
SETIOV( &mx[3], &ptr_event, sizeof( ptr_event ) );

PhEventEmitmx( &event, &rect, 4, mx );
}
I first move the cursor onto a button widget, and get the x,y coordinate
of the button,then emit the button press event, but nothing happened .
Could anyone help me?
thanks!

Hi Bill,

Your code looks correct. Perhaps the x and y coord are wrong?
Maybe you need to perform a translation?



Bill chour <zmc@263.net> wrote:

In Neutrino TRP ,I use following function to Emit a button pressed
event:

void function(int xcoord,int ycoord)
{
PhEvent_t event;
PhRect_t rect;
PhPointerEvent_t ptr_event;
iov_t mx[4];

event.type = Ph_EV_BUT_PRESS;
event.subtype = 0;
event.emitter.rid = Ph_DEV_RID;
event.flags = 0;
event.num_rects = 1;
event.data_len = sizeof( ptr_event );

rect.ul.x = rect.lr.x = xcoord;
rect.ul.x = rect.lr.y = ycoord;

ptr_event.flags = 0;
ptr_event.buttons = Ph_BUTTON_SELECT;
SETIOV( &mx[3], &ptr_event, sizeof( ptr_event ) );

PhEventEmitmx( &event, &rect, 4, mx );
}
I first move the cursor onto a button widget, and get the x,y coordinate
of the button,then emit the button press event, but nothing happened .
Could anyone help me?
thanks!