Opened 3 years ago

Last modified 3 months ago

#15721 reopened defect

SIngle-selection tree control gets focus on wxMSW when items are deleted

Reported by: ikamakj Owned by:
Priority: normal Milestone:
Component: wxMSW Version: 2.9.5
Keywords: wxTreeCtrl delete focus Cc:
Blocked By: #16926 Blocking:
Patch: no

Description

Tree control items may be deleted in response to a keyboard action in some other window, therefore the deletion should not result in focus change. The MSW implementation of wxTreeCtrl has the problem that item deletion may generate a TVN_SELCHANGING event and the handling of this in wxTreeCtrl::MSWOnNotify() calls SetFocus(). With multiple-selection tree controls this call is prevented during deletion by the m_changingSelection flag being set in wxTreeCtrl::Delete(). Is there any reason why the same could not be done for single-selection controls?

Change History (5)

comment:1 Changed 3 years ago by VZ

(In [75306]) Fix unwanted focus events when deleting a wxTreeCtrl item in wxMSW.

Disable setting focus in response to TVN_SELCHANGING when deleting an item in
a single selection control too -- this was already done in multi selection
case but not in this one, for some reason.

See #15721.

comment:2 Changed 3 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [75308]) Fix unwanted focus events when deleting a wxTreeCtrl item in wxMSW.

Disable setting focus in response to TVN_SELCHANGING when deleting an item in
a single selection control too -- this was already done in multi selection
case but not in this one, for some reason.

Also refactor the code to avoid duplicating TreeView_DeleteItem() calls.

Closes #15721.

comment:3 Changed 2 years ago by sky_walker

I have a tree and some additional widgets which depend on the current selected item. Before this fix I received event wxEVT_TREE_SEL_CHANGED when i deleted current item. But now I doesn't have any notification about changed selection though selection in the tree is actually changed.

comment:4 Changed 2 years ago by sky_walker

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:5 Changed 3 months ago by oneeyeman

  • Blocked By 16926 added

See 16926.
We probably should decide whether make single selection and multiple selection tree control behave the same or let the single selection one send the event in case the item is deleted.

Note: See TracTickets for help on using tickets.