I am trying to catch keystrokes and then send an event to particular
widgets, depending on which key is pressed.
I have established code which intercepts keystrokes. Then I have created a
huge switch/case statement which depending on the key, sends events to
different widgets.
I have successfully sent events to toggle buttons. It sets/unsets them and
triggers their activate callback.
I am having trouble with sending events to regular buttons. Here is what I
have tried (per QNX help):
struct {
PhEvent_t event;
PhRect_t rect;
PhPointerEvent_t pEvent;
} new_event;
memset (&new_event.rect, -1, sizeof(new_event.rect) );
new_event.event.processing_flags = Ph_FAKE_EVENT;
new_event.event.num_rects = 1;
new_event.pEvent.buttons = Ph_BUTTON_SELECT;
new_event.event.type = Ph_EV_BUT_PRESS;
PtSendEventToWidget(ABW_Toggle1, (PhEvent_t *) &new_event);
Now this code above works for the toggle button. However when I do the
exact same thing to a regular button:
PtSendEventToWidget(ABW_Button1, (PhEvent_t *) &new_event);
the button goes to a pressed in state, but of course it doesn’t get released
nor does it’s activate callback get triggered.
So…I tried doing a RELEASE event:
new_event.event.processing_flags = Ph_FAKE_EVENT;
new_event.event.num_rects = 1;
new_event.pEvent.buttons = Ph_BUTTON_SELECT;
new_event.event.type = Ph_EV_BUT_RELEASE;
new_event.event.subtype = Ph_EV_RELEASE_PHANTOM;
new_event.pEvent.click_count = 1;
(this code was taken straight from QNX/Photon help page)
PtSendEventToWidget(ABW_Button1, (PhEvent_t *) &new_event);
This does absolutely NOTHING to the button. So then I thought I probably
need to do a PRESS and a RELEASE.
So I set up the following:
new_event.event.processing_flags = Ph_FAKE_EVENT;
new_event.event.num_rects = 1;
new_event.pEvent.buttons = Ph_BUTTON_SELECT;
new_event.event.type = Ph_EV_BUT_PRESS;
PtSendEventToWidget(ABW_Button1, (PhEvent_t *) &new_event);
new_event.event.type = Ph_EV_BUT_RELEASE;
new_event.event.subtype = Ph_EV_RELEASE_PHANTOM;
new_event.pEvent.click_count = 1;
PtSendEventToWidget(ABW_Button1, (PhEvent_t *) &new_event);
This seems to cause a flicker on my screen, but the Activate Callback does
not get triggered.
Can anyone help me with this little problem?