Getting drag events

I am having trouble getting drag events. Here is a simple picture
of what I am trying to do.

±-------------------------------------------------------+
| File
|
±-------------------------------------------------------+
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
±--------±--------------------------------------------+
^ ^ edit area

  • palette area

When I setup up a PhDragInit from the palette area, I
create a new widget with the main window as the parent,
and I do a PhDragInit giving the main window as the
container and the newly created widget rect. When the
widget is eventually dropped into the edit area, it is
reparented to the edit area container (PtContainerScroll).
This works fine; however, when I try to do a PhDragInit
using one of the widgets dropped into the edit area, passing
the edit area as the bounding container, I don’t get any drag
events in either the edit area’s “raw event” callback or
“filtered” callbacks, or in the main windows “raw event” or
“filtered” callbacks.

This is under Photon 2.0, of course. I did a very similar
setup under Photon 1.13 and I don’t recall having any
problems getting this to work. I have reviewed that
project, and everything seems the same wrt this
functionality.

Anyone have any ideas ?

TIA

Rennie

John Doe <john@csical.com> wrote:

I am having trouble getting drag events. Here is a simple picture
of what I am trying to do.

When I setup up a PhDragInit from the palette area, I
create a new widget with the main window as the parent,
and I do a PhDragInit giving the main window as the
container and the newly created widget rect. When the
widget is eventually dropped into the edit area, it is
reparented to the edit area container (PtContainerScroll).
This works fine; however, when I try to do a PhDragInit
using one of the widgets dropped into the edit area, passing
the edit area as the bounding container, I don’t get any drag
events in either the edit area’s “raw event” callback or
“filtered” callbacks, or in the main windows “raw event” or
“filtered” callbacks.

PhInitDrag() doesn’t take a widget – how exactly are you “using” those
widgets with PhInitDrag()?

Is it possible that you’re calling PtWidgetRid() on a widget that
doesn’t happen to have a region, and as a result you’re passing zero to
PhInitDrag()?..

This is under Photon 2.0, of course. I did a very similar
setup under Photon 1.13 and I don’t recall having any
problems getting this to work. I have reviewed that
project, and everything seems the same wrt this
functionality.


Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.

Previously, Wojtek Lerch wrote in qdn.public.qnxrtp.photon:

John Doe <> john@csical.com> > wrote:
I am having trouble getting drag events. Here is a simple picture
of what I am trying to do.

When I setup up a PhDragInit from the palette area, I
create a new widget with the main window as the parent,
and I do a PhDragInit giving the main window as the
container and the newly created widget rect. When the
widget is eventually dropped into the edit area, it is
reparented to the edit area container (PtContainerScroll).
This works fine; however, when I try to do a PhDragInit
using one of the widgets dropped into the edit area, passing
the edit area as the bounding container, I don’t get any drag
events in either the edit area’s “raw event” callback or
“filtered” callbacks, or in the main windows “raw event” or
“filtered” callbacks.

PhInitDrag() doesn’t take a widget – how exactly are you “using” those
widgets with PhInitDrag()?

OK. I have a real internet connection now, so I can
operate from my QNX desktop (so I don’t have to refer
to API calls from my defective memory :slight_smile:

Following is the pertinent code. It is called from two
different callbacks (one attached to the widget when it
is on the palette, and one when it is in the edit area).
The variants are the container, scroll values, and of
course, the callback info (the widget has simply been
re-parented).

In the first (working) case:

the widget has been instantiated with the app base window
as parent

container == the application base window
scroll_x == 0
scroll_y == 0

In the second (non working) case:

the widget has been re-parented to the edit area
(PtScrollContainer)

container == instance of PtScrollContainer class (edit area)
scroll_x == X
scroll_y == Y

where X and Y can vary, but in the specific test case were 0.

int drag_block(PtWidget_t *widget,
PtWidget_t *container,
unsigned short scroll_x,
unsigned short scroll_y,
PtCallbackInfo_t *cbinfo)

{
PhDim_t *dimension;
PhRect_t rect;
PhRect_t boundary;
PtArg_t args[2];

PtWidgetExtent(widget, &rect);

PtSetArg (&args[0], Pt_ARG_DIM, &dimension, 0);
PtGetResources(container, 1, args);
boundary.ul.x = scroll_x;
boundary.ul.y = scroll_y;
boundary.lr.x = (dimension->w-1)+scroll_x;
boundary.lr.y = (dimension->h-1)+scroll_y;

return PhInitDrag(PtWidgetRid(container),
Ph_TRACK_DRAG|Ph_DRAG_TRACK,
&rect, &boundary,
cbinfo->event->input_group,
NULL, NULL, NULL, NULL, NULL);
}

As I mentioned in my first post, I have checked the
return value from PhInitDrag, and in either the working,
or non-working cases there is no error return.

Is it possible that you’re calling PtWidgetRid() on a widget that
doesn’t happen to have a region, and as a result you’re passing zero to
PhInitDrag()?..

This is possible, but I would assume that a
PtScrollContainer has a region, doesn’t it ?


Wojtek Lerch (> wojtek@qnx.com> ) QNX Software Systems Ltd.

Thanks for your response Wojtek.

Rennie