-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Menus without child menuitems should be hidden #1095
Comments
I think it should be disabled instead. |
Well, as the child items are invisible, I think the right thing to do here it to hide it. If the menu was created to be show, then the child menu items will not have "is_visible" returning False. If all child menu items agree to return False for "is_visible" (therefore the menu is empty) then the menu should be hidden too |
Good point. There is no way to set the visible or enabled state of a menu item containing child items, thus you can not tell ST which should be preferred. Usually hiding information should very rarely be done because it confuses users as to why things are "not there". Explicitly disabling something has more feedback. Maybe a new key for |
I've found a workaround: EDIT: this doesn't seem to work in Windows. It at least works in Ubuntu 14.04, ST 3114. Make a command in your plugin whose entire purpose is to check if it should be enabled/visible (either by performing the check directly or by querying all of the children explicitly). For the parent menu item, add a "command" key with a value of your new command. class CfptTest(sublime_plugin.TextCommand):
"""Return the text in the highlighted region
"""
def gettext(self):
region = self.view.sel()[0]
return self.view.substr(region)
"""Disable command when no text selected
"""
def is_enabled(self):
return self.gettext() is not ""
and
|
@duckythescientist, doesn't work for me. Neither It would be a fine solution if it worked however. |
@FichteFoll, interesting. It works with my Ubuntu 14.04, ST 3114, but it doesn't work in my Windows 7 with ST 3114. |
Also hidden them when all its children are invalid. It is necessary for the DamnWidget/anaconda#571. Well, if there is the Or allow the
Which does not work currently work for this menu entry file:
Related threads: |
In a couple of situations all child menu-items are not shown due to "is_visible" because simply the context on which these are triggered is not relevant. However the container of these menu-items(the menu) are still shown empty. Which disturbs a bit, and sometimes may cause confusion.
The text was updated successfully, but these errors were encountered: