I've been working with a wxListCtrl, set up similar to grid,
multiple columns, etc, with Up/Down buttons nearby to let the
user rearrange the list items by moving the highlighted
item up and down.
Problem was, I couldn't get the selected item's highlight
to move with an item as I moved it up and down.
Trying to get and set the item state following the docs didn't
work, ie, this method of moving the highlight didn't go:
Maybe the wxLIST_MASK_STATE doesn't mask the selected state of an
item in the wxListCtrl, IDK. I didn't see any other names in the
list of masks that looked better.
I've been working with a wxListCtrl, set up similar to grid, multiple columns, etc, with Up/Down buttons nearby to let the user rearrange the list items by moving the highlighted
item up and down.
Problem was, I couldn't get the selected item's highlight to move with an item as I moved it up and down.
Trying to get and set the item state following the docs didn't
work, ie, this method of moving the highlight didn't go:
Maybe the wxLIST_MASK_STATE doesn't mask the selected state of an
item in the wxListCtrl, IDK. I didn't see any other names in the
list of masks that looked better.
I think the wxLIST_MASK_STATE constant is used to specify that the m_state member of the wxListItem has a valid value. This is for things like SetItem and such where you are passing a wxListItem object.
However, this worked fine:
theList.SetItemState(
sourcePos, 0, wxLIST_STATE_SELECTED)
theList.SetItemState(
targetPos, wxLIST_STATE_SELECTED,
wxLIST_STATE_SELECTED)
Using zero for unselected and wxLIST_STATE_SELECTED as its own
mask works fine.
Yep, this is the correct way. If you also want the other state flags then you should be able to use code like your first sample, but using wxLIST_STATE_DROPHILITED|wxLIST_STATE_FOCUSED|wxLIST_STATE_SELECTED for the mask.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!