Mouse activate with key modifier

Hi.

I would like to be able to select multiple text widgets in my app.

How can I check if there is a modifier key down (such as SHIFT or CTRL)
during my Pt_CB_ACTIVATE callback?

Gracias!

Augie

Augie Henriques <augieh@scieng.com> wrote:
: Hi.

: I would like to be able to select multiple text widgets in my app.

: How can I check if there is a modifier key down (such as SHIFT or CTRL)
: during my Pt_CB_ACTIVATE callback?

Take a look at the docs for PhEvent_t (subtype Ph_EV_BUT_RELEASE and
Ph_EV_BUT_PRESS) and PhKeyEvent_t.


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems Ltd.

Hi.

Steve Reid <stever@qnx.com> wrote in message
news:8t6n9b$3ol$5@nntp.qnx.com

Augie Henriques <> augieh@scieng.com> > wrote:
: Hi.

: I would like to be able to select multiple text widgets in my app.

: How can I check if there is a modifier key down (such as SHIFT or CTRL)
: during my Pt_CB_ACTIVATE callback?

Take a look at the docs for PhEvent_t (subtype Ph_EV_BUT_RELEASE and
Ph_EV_BUT_PRESS) and PhKeyEvent_t.

Are you saying that I have to attach an extra callback to my widget to check
if a modifier key is behing pressed (pressed but not released)?

I haven’t done much keyboard/event stuff with photon.

A sample of how to check from the Activate callback for a button behing held
would be nice.

Thanks

Augie


Steve Reid > stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems Ltd.

Augie Henriques <augieh@scieng.com> wrote:
: Are you saying that I have to attach an extra callback to my widget to check
: if a modifier key is behing pressed (pressed but not released)?

No. Just remember that the callback data for Pt_CB_ACTIVATE includes a
pointer to the event that caused the callback. That event is going to be
a button release, and the event data includes a field that indicates which
modifier keys are pressed.

: I haven’t done much keyboard/event stuff with photon.

: A sample of how to check from the Activate callback for a button behing held
: would be nice.

I’m afraid I don’t have an example at hand, but it could be a good example
in the docs. I’ll try to cook up an example.


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems Ltd.

Steve Reid <stever@qnx.com> wrote:
: I’m afraid I don’t have an example at hand, but it could be a good example
: in the docs. I’ll try to cook up an example.

And here it is (it should work with Photon 1.14 and 2.0):

/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

/* Toolkit headers */
#include <Ph.h>
#include <Pt.h>
#include <Ap.h>

/* Local headers */
#include “abimport.h”
#include “proto.h”


int
check_keys( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )

{

PhPointerEvent_t *event_data;

/* eliminate ‘unreferenced’ warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;

if (cbinfo->event->type != Ph_EV_BUT_RELEASE) {
printf (“Not a Ph_EV_BUT_RELEASE event\n”);
} else {
printf (“It’s a Ph_EV_BUT_RELEASE event\n”);

event_data = (PhPointerEvent_t *) PhGetData (cbinfo->event);

if (event_data->key_mods & Pk_KM_Shift )
printf (" Shift\n");

if (event_data->key_mods & Pk_KM_Ctrl )
printf (" Ctrl\n");

if (event_data->key_mods & Pk_KM_Alt )
printf (" Alt\n");

}
return( Pt_CONTINUE );

}


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems Ltd.