Hello,
is the Menu Class defined to not overlap an active menu when a new menu gets sent to a player?
Would it be possible to change this behaviour, by making new menus overlap the active ones? (Or as an alternative close active when a new menu gets sent?)
Thanks
Overlap menu's
Re: Overlap menu's
Yes (twice). If you have an active menu and you send another one, it gets added to the end of the queue here:
https://github.com/Source-Python-Dev-Te ... se.py#L173
It doesn't get shown immediately. Only if the user or a plugin closes the active menu, the next one is shown. So, the menus and the queues use the FIFO (First In First Out) concept. The queue also prevents a menu from being added twice. Thus, you don't need to check whether or not it is already present in the queue.
When I developed the menus package, I already planned to add the possibility to have priority menus, but I somehow didn't fully implement it. Thus, it's a little bit hacky to send a priority menu (untested):
Alternatively, you could also subclass the menu classes and re-implement the _send() method.
https://github.com/Source-Python-Dev-Te ... se.py#L173
It doesn't get shown immediately. Only if the user or a plugin closes the active menu, the next one is shown. So, the menus and the queues use the FIFO (First In First Out) concept. The queue also prevents a menu from being added twice. Thus, you don't need to check whether or not it is already present in the queue.
When I developed the menus package, I already planned to add the possibility to have priority menus, but I somehow didn't fully implement it. Thus, it's a little bit hacky to send a priority menu (untested):
Syntax: Select all
from contextlib import contextmanager
from menus.queue import _UserQueue
@contextmanager
def priority_menu():
old = _UserQueue.append
try:
_UserQueue.append = _UserQueue.appendleft
yield
finally:
_UserQueue.append = old
# Test
# Send as usual (FIFO)
my_menu.send()
# Send with highest priority (LIFO)
with property_menu():
my_menu.send()
# Send as usual again (FIFO)
my_menu.send()
Re: Overlap menu's
Thank you Ayuto!
Definitely useful to know. I will try to play with it.
Is there actually a limit how many items a menu can take for example in: PagedMenu
Definitely useful to know. I will try to play with it.
Is there actually a limit how many items a menu can take for example in: PagedMenu
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 85 guests