Skip navigation.
Home
The QNX Community Portal

View topic - Not receiving Pt_ARM_CB in a PtText widget

Not receiving Pt_ARM_CB in a PtText widget

Isn't the name clear?

Not receiving Pt_ARM_CB in a PtText widget

Postby steven_lougheed » Tue May 01, 2007 6:45 pm

When I click on a PtText widget, I receive a Ph_EV_BUT_PRESS event, but no Pt_CB_ARM callback. I could use the button press event, but would prefer to get the arm callback, or even the Activate.

The QNX documentation says that "These callbacks are invoked only if the widget has Pt_SELECTABLE set in its Pt_ARG_FLAGS." So, I made sure that Pt_SELECTABLE flag is set, but there was no change. (http://www.qnx.com/developers/docs/6.3. ... #Pt_CB_ARM)

Anyone know why the callback is not being triggered?

I've attached a very simple Momentics PhAB project with a button and a text widget. They are both set to call a common callback that simply prints the name of the callback that was invoked.

Using QNX 6.3.0 SP2 with Momentics 4.0.1.
steven_lougheed
Active Member
 
Posts: 16
Joined: Fri Feb 23, 2007 6:30 pm

RE: Not receiving Pt_ARM_CB in a PtText widget

Postby maschoen » Wed May 02, 2007 7:01 pm

I don't think text widgets are designed to call callbacks when pressed. Instead a button widget would be more appropriate.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

RE: Not receiving Pt_ARM_CB in a PtText widget

Postby steven_lougheed » Wed May 02, 2007 8:31 pm

I would agree with you, except that the documentation for a PtText goes into some detail about how it receives Pt_CB_ACTIVATE callbacks and I fail to receive these callbacks as well. http://www.qnx.com/developers/docs/6.3. ... B_ACTIVATE

A button would make sense, I really just don't want to go through and change hundreds of text widgets to buttons in PhAB.

.
Attachments
combo_test.zip
Simple callback tester.
(182.34 KiB) Downloaded 282 times
steven_lougheed
Active Member
 
Posts: 16
Joined: Fri Feb 23, 2007 6:30 pm

Postby ingraham » Wed May 02, 2007 8:56 pm

I don't know if this matters, but in your first post you asked about a Pt_CB_ARM and in your later post about Pt_CB_ACTIVATE. Typo, maybe? I've never tried an ARM, but ACTIVATE happens when you press enter; I use Pt_CB_GOT_FOCUS to handle a click event. ACTIVATE does trigger on a click on a PtLabel.

-James Ingraham
Sage Automation, Inc.
ingraham
Senior Member
 
Posts: 160
Joined: Wed Nov 05, 2003 2:25 pm
Location: Texas

Postby mezek » Thu May 03, 2007 7:37 am

In PtText the Pt_CB_ARM and Pt_CB_ACTIVATE work as expected after you enable Pt_SELECTABLE in Pt_ARG_FLAGS. Please read the documentation again.

I still do not understand what is steven_lougheed trying to acomplish.
Maybe the focus callbacks would suit him better.
Anyway, here is a simple example on Pt_CB_ARM and Pt_CB_ACTIVATE

Code: Select all
#include <Pt.h>

void cb_activate (PtWidget_t *wgt, void *user_data, PtCallbackInfo_t *info)
{
   const char *str;
   
   str = user_data;
   printf("%s %s\n", str, "Pt_CB_ACTIVATE");
}

void cb_arm (PtWidget_t *wgt, void *user_data, PtCallbackInfo_t *info)
{
   const char *str;
   
   str = user_data;
   printf("%s %s\n", str, "Pt_CB_ARM");
}

int main (int argc, char *argv [])
{
   PtAppContext_t app;
   PhDim_t dim;
   PhPoint_t pos;
   PtWidget_t *window, *text, *text2;
   PtArg_t args [3];
   int nargs;
   
   dim.w = 120;
   dim.h = 80;
   
   nargs = 0;
   PtSetArg(&args[nargs++], Pt_ARG_DIM, &dim, 0);
   
   if ((window = PtAppInit(&app, &argc, argv, nargs, args)) == NULL)
      return -1;
   
   dim.w = 100;
   dim.h = 20;
   
   pos.x = 5;
   pos.y = 5;
   
   nargs = 0;
   PtSetArg(&args[nargs++], Pt_ARG_DIM, &dim, 0);
   PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
   PtSetArg(&args[nargs++], Pt_ARG_FLAGS, Pt_TRUE, Pt_SELECTABLE);
   
   if ((text = PtCreateWidget(PtText, window, nargs, args)) == NULL)
      return -1;
   
   dim.w = 100;
   dim.h = 20;
   
   pos.x = 5;
   pos.y = 30;
   
   nargs = 0;
   PtSetArg(&args[nargs++], Pt_ARG_DIM, &dim, 0);
   PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
   PtSetArg(&args[nargs++], Pt_ARG_FLAGS, Pt_TRUE, Pt_SELECTABLE);
   
   if ((text2 = PtCreateWidget(PtText, window, nargs, args)) == NULL)
      return -1;
   
   PtAddCallback(text, Pt_CB_ACTIVATE, cb_activate, "text");
   PtAddCallback(text, Pt_CB_ARM, cb_arm, "text");
   PtAddCallback(text2, Pt_CB_ACTIVATE, cb_activate, "text2");
   PtAddCallback(text2, Pt_CB_ARM, cb_arm, "text2");
   
   PtRealizeWidget(window);
   PtMainLoop();
   
   return 0;
}
mezek
Senior Member
 
Posts: 193
Joined: Wed Mar 03, 2004 5:51 pm

Postby steven_lougheed » Thu May 03, 2007 8:34 pm

First, I tried the sample code running on a QNX PC and I still fail to get a Pt_CB_ARM or Pt_CB_ACTIVATE when I use the mouse although I do get a Pt_CB_ACTIVATE when I press enter.

I know that Pt_SELECTABLE needs to be set (discussed in my first post), are there any other settings that could disable the arm or activate callbacks?

Now a little background as to why I care about Pt_CB_ARM. I'm developing a touch screen app with no keyboard/mouse attached so I can't rely on Pt_CB_ACTIVATE from <ENTER>. I have some text that I'd like to be able to edit through the touch screen. So, when you touch the text, a keyboard app pops up allowing you to "type" on the touchscreen. When the keyboard is closed, the text is updated. I could use Pt_CB_GOT_FOCUS on the text, but I have problems when the keyboard app closes. Photon gives focus back to the original screen (with the text) and I have to make sure it doesn't give focus to one of the text boxes as I will then receive another got_focus event and I will then popup the keyboard again.

Admittedly there are ways around my got_focus problem, but it seems much more logical to popup the keyboard app on an ARM event. ACTIVATE might be okay, but it is hard to touch a screen and release within a small text box. Since I should be receiving Pt_CB_ARM events for PtText as long as the Pt_SELECTABLE flag is set, I was surprised when I received neither the ARM or ACTIVATE (or DISARM for that matter) callbacks.
steven_lougheed
Active Member
 
Posts: 16
Joined: Fri Feb 23, 2007 6:30 pm

Postby maschoen » Fri May 04, 2007 3:07 am

Steven,

Here is how I suggest you proceed. Create a minimal application that duplicates this problem, and upload the entire work space. I'm sure someone will check it on their system. If it doesn't work, we'll be able to help you hone in on the problem. If it doesn't work, then that will tell you that the problem is local to your configuration. This response is the first one I've seen that mentioned touch screen. I recall from my own work that touch screens may function a little unexpectedly, for example a particular touch screen might not function exactly the same way a mouse button might with respect to Pt_CB_ARM, Pt_CB_DISARM, and Pt_CB_ACTIVATE.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Postby steven_lougheed » Fri May 04, 2007 2:43 pm

I've actually already attached a minimal application that duplicates my problem although for some reason I didn't explain what I attached.

The file:combo_test.zip (attached in an earlier post) contains a Momentics project with PhAB generated code so there are a fair number of files although the only file I actually edit is common.cc. All callbacks are handled in that file by the aptly named "callback" function which simply prints out the type of callback.

Using my sample app clicking the button produces the following callbacks (in order):
ARM
EV_BUT_PRESS
GOT_FOCUS
BUT_RELEASE
DISARM
ACTIVATE

Clicking the text box produces:
BUT_PRESS
GOT_FOCUS
BUT_RELEASE
along with some MOTION_VERIFY, MOTION_NOTIFY and OUTBOUND (where required) but I don't really care about these callbacks.

So, despite that fact that the Text box has Pt_SELECTABLE set, I still receive no ARM/DISARM/ACTIVATE events.

For those without Momentics or those that hate PhAB, the sample app posted by mezek gives me the same results on my system i.e. no ARM callback, only receive an activate callback when the <ENTER> key is pressed.

Let's forget about the touchscreen for now. I'm testing with a QNX PC with a real mouse and keyboard and still failing to receive the ARM (For the record, it fails in VmWare and with the touchscreen as well). I mentioned the eventual touchscreen application because people were confused why I cared about receiving a Pt_CB_ARM on a text widget and why Pt_CB_GOT_FOCUS would be problematic.
steven_lougheed
Active Member
 
Posts: 16
Joined: Fri Feb 23, 2007 6:30 pm

Postby micro » Thu May 10, 2007 3:23 pm

Did you try for PT_CB_ACTIVATE with subreason 0 (since selec... is set)?
As far as i understood this should not trigger when your onscreenkeyboard pushes back to bg.
micro
Senior Member
 
Posts: 458
Joined: Thu Jul 22, 2004 8:41 pm

Postby micro » Thu May 10, 2007 3:25 pm

oO i guess i did not read carefully enough, there is no ACTIVATE right? ^^
micro
Senior Member
 
Posts: 458
Joined: Thu Jul 22, 2004 8:41 pm

Postby steven_lougheed » Thu May 10, 2007 3:56 pm

I asked QNX directly about this one and this is the response I got:

"This is actually a known bug in the Photon libs. What you can do in
the interm is to setup a filter callback and capture raw mouse click
events and setup a callback on that"

Well, at least it explains why I've been having so much trouble getting it to work.
steven_lougheed
Active Member
 
Posts: 16
Joined: Fri Feb 23, 2007 6:30 pm


Return to GUI Programming

Who is online

Users browsing this forum: No registered users and 2 guests