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

Add function to apply context menu to widget #42

Open
UnsignedArduino opened this issue Oct 22, 2021 · 1 comment
Open

Add function to apply context menu to widget #42

UnsignedArduino opened this issue Oct 22, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@UnsignedArduino
Copy link
Owner

If we add a context menu to a widget that already has on "built-in" (like entries, text, etc.) then it will add it under. Maybe something like this:

def make_menu_for_widget():
    # return a TkZero menu object that has all the commands and everything set to their respective states
    # if nothing is returned then don't show a context menu
    # this function will be called everytime before we show the right-click menu

add_context_menu(widget, make_menu_func=make_menu_for_widget)
@UnsignedArduino
Copy link
Owner Author

Actually, we should never put on a context menu by default, and have a built in function that will return a "standard" right-click menu for typing widgets (like "cut" "copy" and "paste) for widgets.
Maybe an API like this:

from TkZero.Menu import add_context_menu, entry_context_menu, ContextMenu

...

def make_menu_for_widget():
    # return a TkZero menu object that has all the commands and everything set to their respective states
    # if nothing is returned then don't show a context menu
    # this function will be called every time before we show the right-click menu
    menu = ContextMenu(parent)
    # this will add items before and after a "standard" context menu
    menu.items = [(the menu objects we already have, like MenuCommand)] + entry_context_menu(entry) + [(more menu objects)]
    return menu

...

add_context_menu(entry, make_menu_func=make_menu_for_widget)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant