Sublime Forum

Get an arg from sub a menu

#1

Hi, I’m trying to get an argument from a submenu of a menu.

This is the JSON


   {
      "caption":"myPlugin"
      "mnemonic":"D",
      "id":"my_plugin"
      "children":
         {
            "caption":"Fist menu",
            "id":"firs_menu",
            "children":
               {
                  "caption":"Sub menu",
                  "children":
                     {
                        "caption":"Sub menu two",
                        "command":"select_sub_menu",
                        "id":"sub_menu_two",
                        "checkbox":true,
                        "arg":{
                           "menu_id":"somedata"
                        }                        
                     }
                  ]
               }
            ]
         }
      ]
   }
]

this is the py code

class SelectSubMenuCommand(sublime_plugin.WindowCommand):
	def run(self,menu_id):
		print(menu_id)

When I select the menu I receive the error

What I’m doing wrong?
I haven’t found enything about in the documentation or here in the forum.

Someone knows?

0 Likes

#2

You wrote “arg” instead of “args”.

0 Likes

#3

Thanks again FichteFoll ,that is what happens when you code many hours without stop.

0 Likes

#4

I didn’t want to fill the forum only with my questions, so I’ll do other in this topic, if I should create a new topic for the this new question let me know.

I’ve realized that the direction of the sub menus I’m creating are always to the left, unlike the rest of the menus of ST who opens always to the right, there is a option to change this direction?

https://photos-6.dropbox.com/t/2/AAD5nrqpvXoqpoD0WfdWoFIkk8bvpgrqWKuJm79VO949PA/12/11900552/png/32x32/3/1449777600/0/2/Sublime_menu.png/EMKR7QgY29cdIAEgAigB/fWzLGYmVfNJjEArjlqshIwqwP6ZfdomNFq-Nb-25_ak?size_mode=3&size=1280x960

0 Likes

#5

This must be OS-dependant because the default menu specifications are no different from user ones

0 Likes

#6

The weird thing is I’ve other plugin with a similar menu structure, and it opens the sub menus in the right direction. I’ll see the code to understand what I’m doing different.

0 Likes

#7

I realized that if a sub menu hasn’t any shortcut assigned, it will open to the left, if it has, will do to the right.

One good example of that is:

Preferences >> Settings - More (it open to the left)
Preferences >> Font (it open to the right)

At least in windows 10.

0 Likes