Sublime Forum

[SOLVED] Change menu-item text related if (un)checked?

#1

I have an menu item, there the user can select if default mode should used or not. The item will (un)checked and the value also stored to an settings file. By loading ST this setting will used to (un)check the item and use related values in my plugin. That works fine.
My question:
Is there a way to change the menu item text on the fly? It would be nice if the text changes in selection.

If interesting, here the code to load, store and set the checked state:

[code]
import sublime
import sublime_plugin

SETTINGS_TOOL = “ToolUsed.sublime-settings”

class SwitchDefaultModeCommand(sublime_plugin.WindowCommand):
check_state = False
def run(self):
self.check_state = not self.check_state
my_set = sublime.load_settings(SETTINGS_TOOL)
my_set.set(‘default_mode’, self.check_state)
sublime.save_settings(SETTINGS_TOOL)

def is_checked(self):
    return self.check_state

def plugin_loaded():
SwitchDefaultModeCommand.check_state = (
sublime.load_settings(SETTINGS_TOOL).get(‘default_mode’, False))[/code]

0 Likes

#2

override the description() function of your class. From the docs

0 Likes

#3

Thank you, now it works like expected.

0 Likes