Don't understand Pt_ARG_RAWLIST_SELECT_F

Hi,
I have a selected item in my list.

When I select another item, I’m called twice. which seems normal.
But, I hoped to be called once for the unselected and once for the new
selected.
Instead of that, I’m called twice with the same item and pos, only
subtype is 1 then 0. Very strange!
Do I have to remember what was selected before?

Alain.

Alain Bonnefoy wrote:

When I select another item, I’m called twice. which seems normal.
But, I hoped to be called once for the unselected and once for the new
selected.
Instead of that, I’m called twice with the same item and pos, only
subtype is 1 then 0. Very strange!
Do I have to remember what was selected before?

The Pt_ARG_RAWLIST_SELECT_F function is the same as PtGenList’s
selection method, and that method doesn’t do anything more than what’s
necessary to implement PtList’s Pt_CB_SELECTION and PtTree’s
Pt_CB_TREE_SELECTION. In particular, it doesn’t tell you which items
have just been unselected – if you need to know that, you’ll have to
keep track of the selection yourself.

Hi Wojtek,
?!? That’s not what the doc says!
Read from ‘Creating a List Widget’:

PtGenListItem_t *item
A pointer to a PtGenListItem_t
http://www.qnx.com/developer/docs/momentics621_docs/photon/widget_ref/ptgenlistitem_t.html
structure. In Pt_SELECTION_MODE_RANGE selection mode, it’s a pointer
to the first selected item. In other modes, it’s a pointer to the
item that has been selected or unselected.

Alain.


Wojtek Lerch a écrit:

Alain Bonnefoy wrote:

When I select another item, I’m called twice. which seems normal.
But, I hoped to be called once for the unselected and once for the
new selected.
Instead of that, I’m called twice with the same item and pos, only
subtype is 1 then 0. Very strange!
Do I have to remember what was selected before?


The Pt_ARG_RAWLIST_SELECT_F function is the same as PtGenList’s
selection method, and that method doesn’t do anything more than what’s
necessary to implement PtList’s Pt_CB_SELECTION and PtTree’s
Pt_CB_TREE_SELECTION. In particular, it doesn’t tell you which items
have just been unselected – if you need to know that, you’ll have to
keep track of the selection yourself.

Hi Wojtek,
?!? That’s not what the doc says!
Read from ‘Creating a List Widget’:

PtGenListItem_t *item
A pointer to a PtGenListItem_t

http://www.qnx.com/developer/docs/momentics621_docs/photon/widget_ref/ptgenlistitem_t.html

structure. In Pt_SELECTION_MODE_RANGE selection mode, it’s a pointer
to the first selected item. In other modes, it’s a pointer to the
item that has been selected or unselected.

Alain.

If that works as you say, in Pt_SELECTION_MODE_RANGE or
Pt_SELECTION_MODE_MULTIPLE, I really don’t see how can I guess what has
been unselected!

Alain

Wojtek Lerch a écrit:

Alain Bonnefoy wrote:

When I select another item, I’m called twice. which seems normal.
But, I hoped to be called once for the unselected and once for the
new selected.
Instead of that, I’m called twice with the same item and pos, only
subtype is 1 then 0. Very strange!
Do I have to remember what was selected before?


The Pt_ARG_RAWLIST_SELECT_F function is the same as PtGenList’s
selection method, and that method doesn’t do anything more than what’s
necessary to implement PtList’s Pt_CB_SELECTION and PtTree’s
Pt_CB_TREE_SELECTION. In particular, it doesn’t tell you which items
have just been unselected – if you need to know that, you’ll have to
keep track of the selection yourself.

Alain Bonnefoy <alain.bonnefoy@icbt.com> wrote:

Hi Wojtek,
?!? That’s not what the doc says!
Read from ‘Creating a List Widget’:

PtGenListItem_t *item
A pointer to a PtGenListItem_t

http://www.qnx.com/developer/docs/momentics621_docs/photon/widget_ref/ptgenlistitem_t.html

structure. In Pt_SELECTION_MODE_RANGE selection mode, it’s a pointer
to the first selected item. In other modes, it’s a pointer to the
item that has been selected or unselected.

The intent was to say that most of the time, it’s the item you clicked
on or the item that a keystroke just made current (and possibly selected
or unselected). If a click unselect a bunch of items and selects the
one you clicked on, you get only one callback. If you click on one of
selected items, the click unselects everything except the item you
clicked on, but you still get that item in the callback.

Also, there’s a bug in the code that has to do with handling range
selection and the Shift key, causing the callback to sometimes point you
to the wrong end to the selected range. I have just fixed it for 6.3
(thanks for making me look at this stuff…).

If that works as you say, in Pt_SELECTION_MODE_RANGE or
Pt_SELECTION_MODE_MULTIPLE, I really don’t see how can I guess what has
been unselected!

In some cases, you could; but in general, you need to keep track of what
was previously selected yourself, perhaps by setting one of the user
flags (Pt_LIST_ITEM_FLAG_USER[1234]).

Thanks Wojtek,
Alain.

Wojtek Lerch a écrit:

Alain Bonnefoy <> alain.bonnefoy@icbt.com> > wrote:


Hi Wojtek,
?!? That’s not what the doc says!
Read from ‘Creating a List Widget’:











PtGenListItem_t *item
A pointer to a PtGenListItem_t

http://www.qnx.com/developer/docs/momentics621_docs/photon/widget_ref/ptgenlistitem_t.html





structure. In Pt_SELECTION_MODE_RANGE selection mode, it’s a pointer
to the first selected item. In other modes, it’s a pointer to the
item that has been selected or unselected.



The intent was to say that most of the time, it’s the item you clicked
on or the item that a keystroke just made current (and possibly selected
or unselected). If a click unselect a bunch of items and selects the
one you clicked on, you get only one callback. If you click on one of
selected items, the click unselects everything except the item you
clicked on, but you still get that item in the callback.

Also, there’s a bug in the code that has to do with handling range
selection and the Shift key, causing the callback to sometimes point you
to the wrong end to the selected range. I have just fixed it for 6.3
(thanks for making me look at this stuff…).



If that works as you say, in Pt_SELECTION_MODE_RANGE or
Pt_SELECTION_MODE_MULTIPLE, I really don’t see how can I guess what has
been unselected!



In some cases, you could; but in general, you need to keep track of what
was previously selected yourself, perhaps by setting one of the user
flags (Pt_LIST_ITEM_FLAG_USER[1234]).