wrong documentation

last week, i complained about functionality of PhSendEventToWidget() on
SH4. to solve the problem i tried to write my own send-function, which
should work exactly as described in docs

while writing this function, i discovered that the widget’s
raw-callback-list is made out of different callback-types:

typedef struct Pt_class_raw_callback {
unsigned long ev_mask;
int (*ev_f)( PtWidget_t *, PhEvent_t * );
unsigned long ev_extra;
} PtClassRawCallback_t;

as described in docs:

typedef struct Pt_raw_callback {
unsigned long event_mask;
int (*event_f)(
PtWidget_t *,
void *,
PtCallbackInfo_t * );
void *data;
} PtRawCallback_t;


the resulting problem is that maybe (i think so - i don’t claim it) on
sh4 the callback-function parameters are passed in wrong order by
PtSendEventToWidget() so that i get unexpected results - such as useless
pointers or so…

the workaround is that if i write my own widget i have only to use the
upper raw-callback-structure to initialize the callback-list via
widget-creation function (Pt_SET_RAW_CALLBACKS)

in addition it’s strange that if i use PtAddEventHandler() instead of
Pt_SET_RAW_CALLBACKS everything works well without using upper
raw-callback-structure

maybe someone can clear it?

mirtch <mirtch@gmx.net> wrote:

last week, i complained about functionality of PhSendEventToWidget() on
SH4. to solve the problem i tried to write my own send-function, which
should work exactly as described in docs

while writing this function, i discovered that the widget’s
raw-callback-list is made out of different callback-types:

typedef struct Pt_class_raw_callback {
unsigned long ev_mask;
int (*ev_f)( PtWidget_t *, PhEvent_t * );
unsigned long ev_extra;
} PtClassRawCallback_t;

That depends on what you call “the widget’s raw-callback-list”.

Typically, the term “raw callback” refers to the Pt_CB_RAW callback
list, which is a list of PtRawCallbackList_t structures (a
PtRawCallbackList_t structure contains a PtRawCallback_t structure and a
next pointer). Each widget instance has its own list, pointed to by
widget->callbacks. The correct way of adding a callback to this list is
by calling PtSetResources() or PtAddEventHandler().

The PtClassRawCallback_t structure is used by the class-level callback
list, which is a list of PtClassRawCallbackList_t structures (again, a
PtClassRawCallbackList_t structure contains a PtClassRawCallback_t
structure and a next pointer). All the instances of any given widget
class share one list, pointed to by widget->class_rec->callbacks. Once
this list has been created, you can’t modify it: you specify these
callbacks for a new widget class by building an array of
PtClassRawCallback_t’s and giving it to PtCreateWidgetClass() via the
Pt_SET_RAW_CALLBACKS macro.

It’s important not to confuse these two callbacks lists. :slight_smile:

as described in docs:

typedef struct Pt_raw_callback {
unsigned long event_mask;
int (*event_f)(
PtWidget_t *,
void *,
PtCallbackInfo_t * );
void *data;
} PtRawCallback_t;



the resulting problem is that maybe (i think so - i don’t claim it) on
sh4 the callback-function parameters are passed in wrong order by
PtSendEventToWidget() so that i get unexpected results - such as useless
pointers or so…

the workaround is that if i write my own widget i have only to use the
upper raw-callback-structure to initialize the callback-list via
widget-creation function (Pt_SET_RAW_CALLBACKS)

When you’re defining a widget class, yes. (Isn’t that what the
Building Custom Widgets book says?)

When you’re using a widget, you still can attach a Pt_CB_RAW callback
to it, even if it’s your own custom widget class. These callbacks will
be invoked for any events that the class-level callbacks don’t consume.

in addition it’s strange that if i use PtAddEventHandler() instead of
Pt_SET_RAW_CALLBACKS everything works well without using upper
raw-callback-structure

maybe someone can clear it?

Wojtek Lerch wrote:

mirtch <> mirtch@gmx.net> > wrote:
last week, i complained about functionality of PhSendEventToWidget() on
SH4. to solve the problem i tried to write my own send-function, which
should work exactly as described in docs

while writing this function, i discovered that the widget’s
raw-callback-list is made out of different callback-types:

typedef struct Pt_class_raw_callback {
unsigned long ev_mask;
int (*ev_f)( PtWidget_t *, PhEvent_t * );
unsigned long ev_extra;
} PtClassRawCallback_t;

That depends on what you call “the widget’s raw-callback-list”.

Typically, the term “raw callback” refers to the Pt_CB_RAW callback
list, which is a list of PtRawCallbackList_t structures (a
PtRawCallbackList_t structure contains a PtRawCallback_t structure and a
next pointer). Each widget instance has its own list, pointed to by
widget->callbacks. The correct way of adding a callback to this list is
by calling PtSetResources() or PtAddEventHandler().

The PtClassRawCallback_t structure is used by the class-level callback
list, which is a list of PtClassRawCallbackList_t structures (again, a
PtClassRawCallbackList_t structure contains a PtClassRawCallback_t
structure and a next pointer). All the instances of any given widget
class share one list, pointed to by widget->class_rec->callbacks. Once
this list has been created, you can’t modify it: you specify these
callbacks for a new widget class by building an array of
PtClassRawCallback_t’s and giving it to PtCreateWidgetClass() via the
Pt_SET_RAW_CALLBACKS macro.

It’s important not to confuse these two callbacks lists. > :slight_smile:

as described in docs:

typedef struct Pt_raw_callback {
unsigned long event_mask;
int (*event_f)(
PtWidget_t *,
void *,
PtCallbackInfo_t * );
void *data;
} PtRawCallback_t;



the resulting problem is that maybe (i think so - i don’t claim it) on
sh4 the callback-function parameters are passed in wrong order by
PtSendEventToWidget() so that i get unexpected results - such as useless
pointers or so…

the workaround is that if i write my own widget i have only to use the
upper raw-callback-structure to initialize the callback-list via
widget-creation function (Pt_SET_RAW_CALLBACKS)

When you’re defining a widget class, yes. (Isn’t that what the
Building Custom Widgets book says?)

i’d say it doesn’t:
http://www.qnx.com/developer/docs/momentics621_docs/photon/wid_build/anatomy.html#ACTIONS

When you’re using a widget, you still can attach a Pt_CB_RAW callback
to it, even if it’s your own custom widget class. These callbacks will
be invoked for any events that the class-level callbacks don’t consume.

in addition it’s strange that if i use PtAddEventHandler() instead of
Pt_SET_RAW_CALLBACKS everything works well without using upper
raw-callback-structure

maybe someone can clear it?

Wojtek Lerch wrote:

mirtch <> mirtch@gmx.net> > wrote:
last week, i complained about functionality of PhSendEventToWidget() on
SH4. to solve the problem i tried to write my own send-function, which
should work exactly as described in docs

while writing this function, i discovered that the widget’s
raw-callback-list is made out of different callback-types:

typedef struct Pt_class_raw_callback {
unsigned long ev_mask;
int (*ev_f)( PtWidget_t *, PhEvent_t * );
unsigned long ev_extra;
} PtClassRawCallback_t;

That depends on what you call “the widget’s raw-callback-list”.

Typically, the term “raw callback” refers to the Pt_CB_RAW callback
list, which is a list of PtRawCallbackList_t structures (a
PtRawCallbackList_t structure contains a PtRawCallback_t structure and a
next pointer). Each widget instance has its own list, pointed to by
widget->callbacks. The correct way of adding a callback to this list is
by calling PtSetResources() or PtAddEventHandler().

The PtClassRawCallback_t structure is used by the class-level callback
list, which is a list of PtClassRawCallbackList_t structures (again, a
PtClassRawCallbackList_t structure contains a PtClassRawCallback_t
structure and a next pointer). All the instances of any given widget
class share one list, pointed to by widget->class_rec->callbacks. Once

then this doc
http://www.qnx.com/developer/docs/momentics621_docs/photon/wid_build/anatomy.html#DEFINECLASS
is wrong, too

this list has been created, you can’t modify it: you specify these
callbacks for a new widget class by building an array of
PtClassRawCallback_t’s and giving it to PtCreateWidgetClass() via the
Pt_SET_RAW_CALLBACKS macro.

It’s important not to confuse these two callbacks lists. > :slight_smile:

as described in docs:

typedef struct Pt_raw_callback {
unsigned long event_mask;
int (*event_f)(
PtWidget_t *,
void *,
PtCallbackInfo_t * );
void *data;
} PtRawCallback_t;



the resulting problem is that maybe (i think so - i don’t claim it) on
sh4 the callback-function parameters are passed in wrong order by
PtSendEventToWidget() so that i get unexpected results - such as useless
pointers or so…

the workaround is that if i write my own widget i have only to use the
upper raw-callback-structure to initialize the callback-list via
widget-creation function (Pt_SET_RAW_CALLBACKS)

When you’re defining a widget class, yes. (Isn’t that what the
Building Custom Widgets book says?)

When you’re using a widget, you still can attach a Pt_CB_RAW callback
to it, even if it’s your own custom widget class. These callbacks will
be invoked for any events that the class-level callbacks don’t consume.

in addition it’s strange that if i use PtAddEventHandler() instead of
Pt_SET_RAW_CALLBACKS everything works well without using upper
raw-callback-structure

maybe someone can clear it?

mirtch <mirtch@gmx.net> wrote:

Wojtek Lerch wrote:
mirtch <> mirtch@gmx.net> > wrote:
the workaround is that if i write my own widget i have only to use the
upper raw-callback-structure to initialize the callback-list via
widget-creation function (Pt_SET_RAW_CALLBACKS)

When you’re defining a widget class, yes. (Isn’t that what the
Building Custom Widgets book says?)

i’d say it doesn’t:
http://www.qnx.com/developer/docs/momentics621_docs/photon/wid_build/anatomy.html#ACTIONS

You’re absolutely right: it appears that that part of the book still
reflects a very old state of things… I’ll als the docs writers to
update it. Sorry about that…

mirtch <mirtch@gmx.net> wrote:

then this doc
http://www.qnx.com/developer/docs/momentics621_docs/photon/wid_build/anatomy.html#DEFINECLASS
is wrong, too

Yes, it is. Thanks.

Wojtek Lerch <wojtek_l@yahoo.ca> wrote:

You’re absolutely right: it appears that that part of the book still
reflects a very old state of things… I’ll als the docs writers to
^^^ Ask. I meant “ask”.
update it. Sorry about that…