Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CustomTreeCtrl edit label remains stuck forever sometimes #1235

Closed
Nyral opened this issue May 27, 2019 · 2 comments

Comments

@Nyral
Copy link
Contributor

@Nyral Nyral commented May 27, 2019

Windows 10 (or Windows 7)
wxPython 4.0.6 (pip)
Python 3.7.3 [32bit]

From what I can tell, it seems that I'm able to somehow select the label from behind the TextCtrl and trigger a second edit label instance that can't be closed.
Or maybe KillFocus doesn't trigger correctly? I dunno.

Here's me reproducing it with the example from wxDemo:
2019-05-28_01-42-14

Another example (from another GUI):
2019-05-19_20-20-38

@cbeytas

This comment has been minimized.

Copy link
Contributor

@cbeytas cbeytas commented May 29, 2019

When you left-click on a label, a TreeEditTimer is started. After _DELAY (500ms) the tree will edit the label.

If you are already editing the label this shouldn't happen, but the TreeTextCtrl doesn't fully cover the label area. So if you click just outside the TreeTextCtrl, the TREE_HITTEST_ONITEMLABEL test will pass and the timer will be started. After 500ms a second TreeTextCtrl is spawned on top of the old one.

When you change the selection, only the most recent TreeTextCtrl is Destroyed and the old one is left orphaned in the tree.

Could be fixed in customtreectrl.py at the end of the Edit() method:

        if self._editCtrl != None and item != self._editCtrl.item():
            self._editCtrl.StopEditing()

        self._editCtrl = TreeTextCtrl(self, item=item)
        self._editCtrl.SetFocus()

if self._editCtrl is not None, an edit control already exists in the tree.
I believe it should not assign self._editCtrl to a new TreeTextCtrl without guaranteeing the previous one is destroyed.

@Nyral

This comment has been minimized.

Copy link
Contributor Author

@Nyral Nyral commented May 30, 2019

@cbeytas Thank you for looking into this! It means a lot to me.

Based on your explanation, I added a condition for checking self._editCtrl is None.

if self._editCtrl == None:
        self._editCtrl = TreeTextCtrl(self, item=item)
        self._editCtrl.SetFocus()

That seems to have been enough to fix the issue.

ezgif-5-0e14057cff26

In wxDemo you can see that the edit event is triggered multiple times, but a new TreeTextCtrl is not created.

Nyral added a commit to Nyral/Phoenix that referenced this issue May 30, 2019
Nyral added a commit to Nyral/Phoenix that referenced this issue Jun 1, 2019
@RobinD42 RobinD42 closed this in 4d336e1 Jun 4, 2019
RobinD42 added a commit that referenced this issue Sep 14, 2019
Fixes #1235: CustomTreeCtrl edit label remains stuck forever

(cherry picked from commit 4d336e1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.