-
Notifications
You must be signed in to change notification settings - Fork 50
Fix imgui popup menus #695
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
Conversation
@clewis7 ready for review! |
📚 Docs preview built and uploaded! https://www.fastplotlib.org/ver/fix-imgui-popup-menus |
oh wait let me add a test |
I'll wait for test before doing a review :D |
ok so I looked into how we could have a test for this and we can't right now since the offscreen canvas does not have things like click events, we can look into this later, can ask almar. |
e5cbc2d
to
17730c4
Compare
so there is |
I just tried this, works for qt canvas but not offscreen 🤷♂️ . Documenting here for now, let's just merge this and figure it out later. """
Test right click menu
=====================
Screenshot test for the right click menu
"""
# test_example = true
# sphinx_gallery_pygfx_docs = 'hidden'
import fastplotlib as fpl
import numpy as np
figure = fpl.Figure(size=(700, 560))
# for some reason right click menu doesn't show if the scene is completely empty
figure[0, 0].add_image(np.zeros((2, 2)), cmap="gray")
figure[0, 0].axes.visible = False
figure.show()
data = {"x": 10, "y": 10, "modifiers": (), "n_touches": 0, "touches": {}}
move = {
"event_type": "pointer_move",
"button": 0,
"buttons": (),
**data,
}
down = {
"event_type": "pointer_down",
"button": 2,
"buttons": (2,),
**data,
}
up = {
"event_type": "pointer_up",
"button": 2,
"buttons": (),
**data,
}
figure.canvas.submit_event(move)
figure.canvas.submit_event(down)
figure.canvas.submit_event(up)
if __name__ == "__main__":
print(__doc__)
fpl.loop.run() |
fixes #694
The kwargs for the imgui popup menu for right clicks got more strict in the v1.6.0 release. Was annoying to troubleshoot since I was first getting errors stating that the previous imgui frame had not been ended and to call
imgui.end_frame()
. So then I added an extraimgui.end_frame()
within the right click menu and it produced the actual error which was that imgui wasn't happy with the types of the kwargs 🤷♂️So before we had things like this for example:
args are: (item name, keyboard shortcut, selected)
So before it worked if we gave
None
for the second arg which is keyboard shortcut, now it has to explicitly be""
. And it's not taking expressions that results in abool
for whatever reason anymore.So in summary the above needs to become the following for imgui v1.6.0 to be happy: