Hey,
Is there a way to return the menu when the player trys to close it via "0"?
I tried it with choice_index == 0 but it didnt worked or more nothing happens
choice_index == 0
Select callbacks don't get called when the close button was pressed. This behaviour is defined here:
https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/addons/source-python/packages/source-python/menus/radio.py#L105
But you can easily extend and update the default behaviour by subclassing the menu class.
https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/addons/source-python/packages/source-python/menus/radio.py#L105
But you can easily extend and update the default behaviour by subclassing the menu class.
Syntax: Select all
from menus.radio import BUTTON_CLOSE
from menus.radio import SimpleRadioMenu
class SimpleMenuExtension(SimpleRadioMenu):
def __init__(self, *args, on_close_menu=None, **kwargs):
super().__init__(*args, **kwargs)
self.on_close_menu = on_close_menu
def _select(self, player_index, choice_index):
if choice_index == BUTTON_CLOSE and self.on_close_menu is not None:
return self.on_close_menu(self, player_index)
return super()._select(player_index, choice_index)
def on_close_menu(menu, player_index):
# Return your menu here
pass
menu = SimpleMenuExtension(on_close_menu=on_close_menu)
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 79 guests