Opened 2 years ago

Closed 22 months ago

Last modified 2 months ago

#15166 closed defect (fixed)

wxTreeCtrl loses focus after Freeze and Thaw

Reported by: andrew.derek.ward Owned by: vadz
Priority: normal Milestone: 3.0.0
Component: wxMSW Version: stable-latest
Keywords: wxTreeCtrl wxWindowUpdateLocker Freeze Thaw regression Cc:
Blocked By: Blocking:
Patch: no

Description

This can be reproduced by modifying the treectrl sample to include these lines in MyTreeCtrl::OnTreeKeyDown:

if (event.GetKeyEvent().GetKeyCode() == 'A')
{

wxWindowUpdateLocker noUpdates(this);

}

Then run the sample and press the 'a' key while one of the wxTreeCtrl nodes has focus. After the key has been pressed the wxTreeCtrl no longer has focus.

This did not happen in wxWidgets 2.9.4

Change History (4)

comment:1 Changed 2 years ago by vadz

  • Keywords regression added
  • Milestone changed from 2.9.5 to 3.0

Could you please try to bisect the history to find out which revision exactly broke this?

comment:2 Changed 22 months ago by vadz

  • Owner set to vadz
  • Status changed from new to accepted

This is almost certainly due to r72665... Now the question is what to do about it. We could try to restore the focus back to the control if it had before being hidden, but this risks resulting in more problems (e.g. breaking the user code if it calls SetFocus() in the meanwhile). So maybe better would be to not hide and show it back at all but do something else, e.g. resize it to very small size while it's frozen. Let me experiment with this...

comment:3 Changed 22 months ago by VZ

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

(In [74072]) Change wxMSW wxTreeCtrl::DoFreeze() to not hide the tree any more.

Hiding the tree when it's frozen, as done in r72665, results in its own
problems, e.g. loss of focus. So don't do this but resize the control to a
very small size when freezing it and restore it to its old size afterwards.

Closes #15166.

comment:4 Changed 2 months ago by sbrowne

I just wanted to post an observation regarding r74072 since it was not obvious when I was debugging. So far it has only affected one area of our code, but that revision will break any calls to HitTest if the tree is frozen. One other observation is that we have at least one other tree whose parent has a blue background behind it and sometimes the parent will redraw while the tree is frozen which ends up creating even more flicker.

I don't really have any ideas on how to improve this at the moment, but I just thought I'd point out some of these issues.

Note: See TracTickets for help on using tickets.