Skip to content
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

feat: allow frontend code in events #80

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mariobuikhuizen
Copy link
Collaborator

@mariobuikhuizen mariobuikhuizen commented Sep 18, 2023

Making the following possible:

import ipyvuetify as v

activator = v.Sheet(style_="width: 500px; height: 500px", elevation=8)
activator.on_event("contextmenu.prevent", "menu.on.click")

v.Sheet(children=[
    v.Menu(
        v_slots=[
            {
                "name": "activator",
                "variable": "menu",
                "children": [activator],
            }
        ],
        absolute=True,
        children=[
            v.Btn(children=["hi"])
        ],
        
    ),
])

One thing I noticed though, is that we need an extra right-click to show the menu on a different spot. So it might not be useful for the original envisioned use-case.

Copy link
Collaborator

@maartenbreddels maartenbreddels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
Any idea why this extra click is needed, is that an issue that needs solving?

I guess we could also do a UI test for this PR right? For instance a context menu?

self._event_handlers_map[event_and_modifiers] = CallbackDispatcher()

self._event_handlers_map[event_and_modifiers].register_callback(
callback, remove=remove
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly unrelated but I think this code (81-95) is very hard to read, or does not work. The register_callback call with remove=True is a no-op or maybe it gives an exception?
Would make me feel more comfortable is we had a test for this.

@mariobuikhuizen
Copy link
Collaborator Author

Any idea why this extra click is needed, is that an issue that needs solving?

It's just how Vuetify menu works. Click out-side first closes the menu, the next click opens the menu on the new position. This is fine for menu, but as a context menu this is a bit unexpected.

@maartenbreddels
Copy link
Collaborator

Right, that means for solara, we probably need a custom template anyway.
I found this example https://codesandbox.io/s/vuetify-context-menu-opened-multiple-times-idstb?file=/src/main.js which seems impossible to do without a vue template.
cc @iisakkirotko

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.

2 participants