Not receiving Pt_ARM_CB in a PtText widget

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. (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.

I don’t think text widgets are designed to call callbacks when pressed. Instead a button widget would be more appropriate.

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. 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.

.

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.

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

#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;
}

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 . 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,

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.

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 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.

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.

oO i guess i did not read carefully enough, there is no ACTIVATE right? ^^

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.