OpenQNX :: The QNX Community Portal

Jul 05, 2008 - 12:12 AM
Google
  Web openqnx.com   
     Create an account Home · Submit News · QNX Forums · QNX Download · Search   
_
Main Menu
Who's Online
There are 51 unlogged users and 0 registered users online.

You can log-in or register for a user account here.

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
steven_lougheed
Post subject: Not receiving Pt_ARM_CB in a PtText widget  PostPosted: May 01, 2007 - 06:45 PM
Active Member


Joined: Feb 23, 2007
Posts: 16

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.0/photon/widget_ref/ptbasic.html#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.
 
 View user's profile Send private message  
Reply with quote Back to top
maschoen
Post subject: RE: Not receiving Pt_ARM_CB in a PtText widget  PostPosted: May 02, 2007 - 07:01 PM
QNX Master


Joined: Jun 25, 2003
Posts: 1027

I don't think text widgets are designed to call callbacks when pressed. Instead a button widget would be more appropriate.
 
 View user's profile Send private message Send e-mail Visit poster's website  
Reply with quote Back to top
steven_lougheed
Post subject: RE: Not receiving Pt_ARM_CB in a PtText widget  PostPosted: May 02, 2007 - 08:31 PM
Active Member


Joined: Feb 23, 2007
Posts: 16

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.0/photon/widget_ref/pttext.html#Pt_CB_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.

.



combo_test.zip
 Description:
Simple callback tester.

Download
 Filename:  combo_test.zip
 Filesize:  182.34 KB
 Downloaded:  107 Time(s)

 
 View user's profile Send private message  
Reply with quote Back to top
ingraham
Post subject:   PostPosted: May 02, 2007 - 08:56 PM
Active Member


Joined: Nov 05, 2003
Posts: 68
Location: Texas
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.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
mezek
Post subject:   PostPosted: May 03, 2007 - 07:37 AM
Senior Member


Joined: Mar 03, 2004
Posts: 185

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:

#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;
}
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
steven_lougheed
Post subject:   PostPosted: May 03, 2007 - 08:34 PM
Active Member


Joined: Feb 23, 2007
Posts: 16

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.
 
 View user's profile Send private message  
Reply with quote Back to top
maschoen
Post subject:   PostPosted: May 04, 2007 - 03:07 AM
QNX Master


Joined: Jun 25, 2003
Posts: 1027

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.
 
 View user's profile Send private message Send e-mail Visit poster's website  
Reply with quote Back to top
steven_lougheed
Post subject:   PostPosted: May 04, 2007 - 02:43 PM
Active Member


Joined: Feb 23, 2007
Posts: 16

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.
 
 View user's profile Send private message  
Reply with quote Back to top
micro
Post subject:   PostPosted: May 10, 2007 - 03:23 PM
Senior Member


Joined: Jul 22, 2004
Posts: 325

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.
 
 View user's profile Send private message  
Reply with quote Back to top
micro
Post subject:   PostPosted: May 10, 2007 - 03:25 PM
Senior Member


Joined: Jul 22, 2004
Posts: 325

oO i guess i did not read carefully enough, there is no ACTIVATE right? ^^
 
 View user's profile Send private message  
Reply with quote Back to top
steven_lougheed
Post subject:   PostPosted: May 10, 2007 - 03:56 PM
Active Member


Joined: Feb 23, 2007
Posts: 16

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.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
All logos and trademarks in this site are property of their respective owners. The comments are property of their posters.
Powered by OpenQNX: The QNX Community Portal Site
QNX and the QNX logo are registered trademarks of QNX Software Systems.