w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to change the status of a Context.sublime-menu item on Sublime Text?

You would have to create a command for each action, but you may be able to leverage the is_visible method. Here is an example of it's usage.

class AdvancedNewFileAtCommand(sublime_plugin.WindowCommand):
    def run(self, dirs):
        if len(dirs) != 1:
            return
        path = dirs[0]
        self.window.run_command("advanced_new_file", {"initial_path": path
+ os.sep})


    def is_visible(self, dirs):
        settings =
sublime.load_settings("AdvancedNewFile.sublime-settings")
        return settings.get("show_sidebar_menu", False) and len(dirs) == 1

I check for a setting and the number of directories specified. This particular example is used to selectively display a Side Bar context menu.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.