Hello everyone,
how can I add a submenu to a PagedMenu? I've looked in the menus package but I couldn't find anything related to submenus, or, how to attach one to a PagedMenu, at least.
Edit: I know how to do it on my own but I'm wondering whether there is a more SP way to do it other than subclassing the PageMenu class.
Submenus
Re: Submenus
Are you looking for something like this?
Syntax: Select all
from menus import PagedMenu
from menus import PagedOption
sub_menu1 = PagedMenu()
sub_menu2 = PagedMenu()
main_menu = PagedMenu(
[
PagedOption('Submenu 1', sub_menu1),
PagedOption('Submenu 2', sub_menu2),
]
)
@main_menu.register_select_callback
def main_menu_select(menu, index, option):
return option.value
Re: Submenus
Oh so I'm doing it the correct way. Thank you :D
Last edited by BackRaw on Sun Dec 03, 2017 8:03 pm, edited 1 time in total.
Re: Submenus
Another question:wouldn't it be better to have a register_close_callback included as well? I can override _select(), but I figure it would be better for SP to provide the mechanism.
Re: Submenus
Yes, that would be a nice addition. Do you want to create a PR?
Re: Submenus
I'm on it!
Re: Submenus
Should it only be called when a player closes the menu or when menu._close() is called on unload and so on as well?
Re: Submenus
I would only call it when the button has been pressed.
Re: Submenus
Ayuto wrote:I would only call it when the button has been pressed.
Done! :D
Re: Submenus
I have noticed that the Wiki didn't get updated with the close_callback API documentation (http://wiki.sourcepython.com/developing ... radio.html). Is that my fault or is it compiled separately from the plugin builds (build bot)?
Re: Submenus
No, everything is fine. Since a few months we have to update it manually.
Re: Submenus
Ayuto wrote:No, everything is fine. Since a few months we have to update it manually.
Good to know thanks.
Return to “Plugin Development Support”
Who is online
Users browsing this forum: Bing [Bot] and 23 guests