Prevent UI events from propagating beyond imgui#569
Conversation
almarklein
left a comment
There was a problem hiding this comment.
I think the general approach is good. I made a few comments.
We should also document this as part of the jupyter_rfb event spec, but I can do that later.
|
Yay! Related: pygfx/pygfx#832 Nice that this PR seems to fix it in a general way |
|
Updated. :) |
If not, I'm fine with merging this. |
We need to provide a way to control the priority order of UI event propagation. For example, we would generally expect Imgui's event handler to be at the front of the queue. However, we cannot guarantee the order in which users initialize the ImguiRenderer and Pygfx Renderer, so we cannot control the insertion order in which the event handlers are added. |
There was a problem hiding this comment.
Looking good. I can't think of a better way to control the order.
We can merge this before #573, so it ends up in the 0.17 release. Otherwise it will be part of a next release, which is also fine.
After a UI event is handled by imgui, we generally don't want the event to be further processed by subsequent handlers (e.g., Pygfx).
For instance, in the following case, it is quite inconvenient
1.mp4
This PR allows imgui to capture canvas UI events and prevent them from further propagation, as shown below:
2.mp4
PS: The implementation might be a bit hacky, 😅 , and I’d be happy to hear your thoughts or suggestions.