Sorry, something went wrong.
|
📚 Docs preview built and uploaded! https://www.fastplotlib.org/ver/fix-imgui-popup-menus |
Sorry, something went wrong.
|
oh wait let me add a test |
Sorry, something went wrong.
|
I'll wait for test before doing a review :D |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
so there is canvas.submit_event() which we can use to offscreen test the right click menu :D |
Sorry, something went wrong.
|
so there is canvas.submit_event() which we can use to offscreen test the right click menu :D 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()
|
Sorry, something went wrong.
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 extra imgui.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 a bool for whatever reason anymore.
So in summary the above needs to become the following for imgui v1.6.0 to be happy: