Merge pull request #3254 from Seannio/main
EvMenu Tooltip Functionality
This commit is contained in:
commit
884df4808c
1 changed files with 8 additions and 1 deletions
|
|
@ -911,7 +911,9 @@ class EvMenu:
|
||||||
|
|
||||||
# validation of the node return values
|
# validation of the node return values
|
||||||
|
|
||||||
# if the nodetext is a list/tuple, the second set is the help text.
|
# if the nodetext is a list/tuple, the second set is the help text.
|
||||||
|
# helptext can also be a dict, which allows for tooltip command-text (key-value) pairs.
|
||||||
|
|
||||||
helptext = ""
|
helptext = ""
|
||||||
if is_iter(nodetext):
|
if is_iter(nodetext):
|
||||||
nodetext, *helptext = nodetext
|
nodetext, *helptext = nodetext
|
||||||
|
|
@ -1084,6 +1086,8 @@ class EvMenu:
|
||||||
self.goto(goto_node, raw_string, **(goto_kwargs or {}))
|
self.goto(goto_node, raw_string, **(goto_kwargs or {}))
|
||||||
elif self.auto_look and cmd in ("look", "l"):
|
elif self.auto_look and cmd in ("look", "l"):
|
||||||
self.display_nodetext()
|
self.display_nodetext()
|
||||||
|
elif self.auto_help and isinstance(self.helptext, dict) and cmd in self.helptext:
|
||||||
|
self.display_tooltip(cmd)
|
||||||
elif self.auto_help and cmd in ("help", "h"):
|
elif self.auto_help and cmd in ("help", "h"):
|
||||||
self.display_helptext()
|
self.display_helptext()
|
||||||
elif self.auto_quit and cmd in ("quit", "q", "exit"):
|
elif self.auto_quit and cmd in ("quit", "q", "exit"):
|
||||||
|
|
@ -1105,6 +1109,9 @@ class EvMenu:
|
||||||
|
|
||||||
def display_helptext(self):
|
def display_helptext(self):
|
||||||
self.msg(self.helptext)
|
self.msg(self.helptext)
|
||||||
|
|
||||||
|
def display_tooltip(self, cmd):
|
||||||
|
self.msg(self.helptext.get(cmd))
|
||||||
|
|
||||||
# formatters - override in a child class
|
# formatters - override in a child class
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue