pazz / urwidtrees

tree widgets for urwid
GNU General Public License v3.0
52 stars 18 forks source link

Emit "modified" signal on focus change #13

Closed johanfforsberg closed 9 years ago

johanfforsberg commented 9 years ago

I believe this is consistent with how the urwid ListWalker works. Is there another way to get notified about focus changes?

pazz commented 9 years ago

I must admit the contents of urwid.ListBox are complete voodoo to me. I do not see any such invocation in ListBox.set_focus. Could it be that we should use connect_signal here?

johanfforsberg commented 9 years ago

Hm, it is used by SimpleListWalker in the set_focus() method, but not by SimpleFocusListWalker which instead relies on MonitoredFocusList which has some magic to keep track of the focus, AFAICT. Probably simplest to just use _modified() in this case..?

johanfforsberg commented 9 years ago

OTOH, how does the tre handle focus if the list of siblings changes "underfoot"? Perhaps the MonitoredFocusList is needed anyway...

pazz commented 9 years ago

there is no smart handling of the focus in TreeBox when you manipulate the underlying Tree. Since I don't know better I'm relying on wardi judgement here, who say'd this patch is safe and reasonable. thanks

johanfforsberg commented 9 years ago

Great!

I noticed that a focused node that is removed sticks around after refresh(). But I don't really see how this could be handled in a way that will always work, e.g. what to do with focus if a node is renamed; how could the tree know? So it's probably better to leave all this handling to the user and keep things simple.

BTW, thanks for this library, it made my tree code a lot simpler.