sending events to widgets

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?

Hi David,

I have made a suggestion below. Let me know if it works…

Regards
Brenda

David Hurlburt wrote:

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;


Did you try setting the
new_event.event.subtype = Ph_EV_RELEASE_REAL;

By setting the subtype to Ph_EV_RELEASE_PHANTOM you are actually using
the disarm callback instead of the activate callback.




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?

Hi David,

Here is a little more background info for you that might help with
knowning what events in the case of a real mouse – you would get even
more events:

  • a PRESS,
  • a RELEASE REAL,
  • a RELEASE PHANTOM,
    and then, after a while ( usually about 1.25ms), a RELEASE ENDCLICK.

For a double (or triple, etc. ) click, you would get the set of a PRESS
and the REAL and PHANTOM releases twice ( or three times, etc.) followed
by a single ENDCLICK.

If the REAL release is missing, it means that it went somewhere else
(i.e. you probably moved the pointer out of the button before
releasing). And PtButton decides that that means that you didn’t want
to activate the button – that is why you were getting the disarm
callback instead.

Even though it doesn’t matter for ( today’s version of ) PtButton
whether you emit the PHANTOM and the ENDCLICK or not, it’s safer in
general to emit the full sequence – some widgets may put themselves in
a wierd state if an event they expect doesn’t arrive.

Hope this helps
Regards
Brenda


GUI Group wrote:

Hi David,

I have made a suggestion below. Let me know if it works…

Regards
Brenda

David Hurlburt wrote:

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;


\


Did you try setting the
new_event.event.subtype = Ph_EV_RELEASE_REAL;

By setting the subtype to Ph_EV_RELEASE_PHANTOM you are actually using
the disarm callback instead of the activate callback.




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?
\

Hi Brenda,

Did you try setting the
new_event.event.subtype = Ph_EV_RELEASE_REAL;

By setting the subtype to Ph_EV_RELEASE_PHANTOM you are actually using
the disarm callback instead of the activate callback.

Thank you for telling me that the Phantom does the disarm cb. That is
helpful.

I did try a “REAL” release but that did not do anything either.

I think it may be just as good to call the ActivateCB directly. Sort of a
no-no, I know. But it works :slight_smile:


“GUI Group” <gui@qnx.com> wrote in message news:3C33727B.3040808@qnx.com

Hi David,

I have made a suggestion below. Let me know if it works…

Regards
Brenda

David Hurlburt wrote:

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;

\


Did you try setting the
new_event.event.subtype = Ph_EV_RELEASE_REAL;

By setting the subtype to Ph_EV_RELEASE_PHANTOM you are actually using
the disarm callback instead of the activate callback.




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?
\

Hi David,

Just to double check for the activate callback to get called it needs
the following event types
Ph_EV_BUT_PRESS and then the Ph_EV_RELEASE_REAL only once both these
events are received is the activate callback called.

And the disarm callback need the Ph_EV_BUT_PRESS and then followed by
the Ph_EV_RELEASE_PHANTOM

Regards
Brenda

David Hurlburt wrote:

Hi Brenda,


Did you try setting the
new_event.event.subtype = Ph_EV_RELEASE_REAL;

By setting the subtype to Ph_EV_RELEASE_PHANTOM you are actually using
the disarm callback instead of the activate callback.



Thank you for telling me that the Phantom does the disarm cb. That is
helpful.

I did try a “REAL” release but that did not do anything either.

I think it may be just as good to call the ActivateCB directly. Sort of a
no-no, I know. But it works > :slight_smile:


“GUI Group” <> gui@qnx.com> > wrote in message news:> 3C33727B.3040808@qnx.com> …

Hi David,

I have made a suggestion below. Let me know if it works…

Regards
Brenda

David Hurlburt wrote:


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;

\


Did you try setting the
new_event.event.subtype = Ph_EV_RELEASE_REAL;

By setting the subtype to Ph_EV_RELEASE_PHANTOM you are actually using
the disarm callback instead of the activate callback.





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?


\