Skip to content

menus.PagedMenu() idea of "back" option #53

@high-voltage

Description

@high-voltage

It would be really nice if we could bind the "Back"-button in the first page of a PagedMenu() manually in our scripts. Example script of how it could look in usage:

def some_menu(index):
    menu = SimpleMenu()
    menu.append(SimpleOption(1, "some other menu", 1)
    menu.select_callback = some_menu_callback
    menu.send(index)

def some_menu_callback(menu, index, option):
    if option.value == 1:
        some_other_menu(index)

def some_other_menu(index):
    # create a paged menu with 2 pages
    menu = PagedMenu()
    for x in range(1, 10):
        menu.append(PagedOption(x, x))

    # this would tell the PagedMenu that we want to bind the "Back"-button on the first page on ourselves
    # the argument is what would be passed as option.value in the callback
    menu.add_back_option('go_back')

    menu.select_callback = some_other_menu_callback
    menu.send(index)

def some_other_menu_callback(menu, index, option):
    if option.value == "go_back":
        # would be only called if we are in the first page of the menu, otherwise behave normally
        return some_menu(index)

    print(option.value)

Might not be the best way to do this, but it's just an idea so you know what I mean.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions