← 返回首页
Fix imgui popup menus by kushalkolar · Pull Request #695 · fastplotlib/fastplotlib · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Fix imgui popup menus#695

Merged
clewis7 merged 4 commits into
mainfrom
fix-imgui-popup-menus
Jan 26, 2025
Merged

Fix imgui popup menus#695
clewis7 merged 4 commits into
mainfrom
fix-imgui-popup-menus

Conversation

kushalkolar commented Jan 17, 2025
edited
Loading

Copy link
Copy Markdown
Member

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:

imgui.menu_item("item name", None, val > 0) # signature menu_item(str, str, bool)

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:

menu_item("item name", "", bool(val > 0))

kushalkolar requested a review from clewis7 as a code owner January 17, 2025 01:17

Copy link
Copy Markdown
Member Author

@clewis7 ready for review!

github-actions Bot commented Jan 17, 2025
edited
Loading

Copy link
Copy Markdown

📚 Docs preview built and uploaded! https://www.fastplotlib.org/ver/fix-imgui-popup-menus

Copy link
Copy Markdown
Member Author

oh wait let me add a test

clewis7 commented Jan 20, 2025

Copy link
Copy Markdown
Member

I'll wait for test before doing a review :D

Copy link
Copy Markdown
Member Author

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.

kushalkolar force-pushed the fix-imgui-popup-menus branch from e5cbc2d to 17730c4 Compare January 25, 2025 06:22

Copy link
Copy Markdown
Member Author

so there is canvas.submit_event() which we can use to offscreen test the right click menu :D

#705 (comment)

Copy link
Copy Markdown
Member Author

so there is canvas.submit_event() which we can use to offscreen test the right click menu :D

#705 (comment)

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()

clewis7 merged commit f3c7879 into main Jan 26, 2025
clewis7 deleted the fix-imgui-popup-menus branch January 26, 2025 02:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

right click menu is broken

2 participants

Footer

© 2026 GitHub, Inc.