Home Download Buy Blog Forum Support

Can a package create a subtree menu?

Can a package create a subtree menu?

Postby asmodai on Mon Aug 09, 2010 12:50 pm

So for my package I am trying to create a menu structure, is there any way to do so?

Right now I just have a simple menu option in my Name.package-menu to run the major command:

Code: Select all
<menu>
    <item caption="Name" command="doAction"/>
</menu>


I would like a submenu to present a small list of options from which to select one option which my package can detect, kind of like the Build System submenu. Is this currently possible?

Edit: And then you stumble across http://www.sublimetext.com/docs/menus via a Google search. Lets see if that can help me out a bit.

Edit2: You can build submenus by simply doing something like the following:

Code: Select all
<menu caption="Name">
    <item caption="NormalCommand" command="doCommand"/>
    <menu caption="SubMenu">
       <item caption="Option1" command="doSomething"/>
    </menu>
</menu>


Still need to see how to make this a radio button kind of menu though.
asmodai
 
Posts: 73
Joined: Mon Mar 01, 2010 10:42 am

Re: Can a package create a subtree menu?

Postby asmodai on Tue Aug 10, 2010 10:50 am

So suppose you have a submenu like the following, where only one value is active at a time (typical radio button):

Code: Select all
<menu caption="Name">
    <menu caption="SubMenu">
       <item caption="Option 1" command="set pluginOption 1"/>
       <item caption="Option 2" command="set pluginOption 2"/>
    </menu>
</menu>


Now in your plugin code you can do something like:

Code: Select all
option = int(view.options().getString('pluginOption')) or 1


This means it will set option to whatever the user clicked on or otherwise default to 1.
asmodai
 
Posts: 73
Joined: Mon Mar 01, 2010 10:42 am


Return to Plugin Development

Who is online

Users browsing this forum: ilyuh, Yahoo [Bot] and 8 guests