Forum Archive

[share code] How to programatically control the editor actions

JonB

https://gist.github.com/c9f42c81c53b276b6560
I stumbled across the NSUserDefaults (omz had used it for the theme editor) and noticed editor actions are there. Here is a set of utilities for adding or removing editor actions, programatically. (for instance, i am going to put in a pull request for stash to self install an editor action).

especially useful since deleting an action through the menu seems to crash on my device anyway. Also, since you cannot tell the path from the action menu, this lets you check which copy of a script you are using.

ywangd

Is it possible to programmatically add an action with arguments?

It seems to me that the UI for adding arguments is currently bugged in 2.0. You can add arguments, but they are NOT saved once you click "Done". It would be great to have a fix with your script.

JonB

Unfortunately, i don't know the key name for the arguments, since they are not being saved in 2.0 (anyone still have the beta? we could check there)

Phuket2

@JonB , sorry my comment is off on a little tangent. But it appears that a lot of what is exposed with objc_utils seems to be discovery. I haven't even tried using objc_utils. A good reason for me, until I get my head around |python, I feel I would be just be digging a deeper grave for myself.
But something nags in my head about iterating through the prototypes with made up params

JonB

updated for beta 20100 with arguments

ywangd

@JonB Thanks for the update.

It seems to me that an extra parameter is needed for function add_action to actually allow user specified arguments like the follows:

def add_action(scriptName,iconName='python',iconColor='',title='', arguments=None):

I tested and it worked with 2.0.