Enumerate MoI commands from a startup script?
All  1  2-5

Previous
Next
 From:  Michael Gibson
10349.2 In reply to 10349.1 
Hi Larry,

re:
> Seems like I ought to be able to get there by walking though the SidePanePalettes but
> I haven't quite figured out how to do that. Or maybe there is a better way?

You could try the same way that Max's script menu does it which is by getting the commands folder using:
code:
var dir = moi.filesystem.getCommandsDir();


And then you can iterate through all files ending in .js in that directory using:
code:
var files = moi.filesystem.getFiles( dir, '*.js' );


Going through the buttons in the side pane would be something like this:

code:
var buttons = moi.ui.sidePane.document.getElementsByTagName( 'moi:CommandButton' );

for ( var i = 0; i < buttons.length; ++i )
{
    var command = buttons.item(i).getAttribute( 'command' );
}



- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Larry Fahnoe (FAHNOE)
10349.3 In reply to 10349.2 
Perfect, thanks as always Michael!!

--Larry
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Larry Fahnoe (FAHNOE)
10349.4 In reply to 10349.2 
Hi Michael,

Well I replied a bit too soon... ;-}

So of the 62 buttons, there are 32 with command attributes 20 with commanset attributes, 7 with onclick attributes and 3 that are visibility:hidden. How would I go about finding the commands within the commandsets? Earlier I'd written a little script to dump the nodes of the moi.ui.sidePane.document, but I didn't find any hints about how to see the contents of the commandsets. I suppose I could parse the commands/*.xml files, but I'm guessing that MoI already has done that.

--Larry
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Michael Gibson
10349.5 In reply to 10349.4 
Hi Larry, yes you would need to load the xml files and go through their contents. MoI does not do that itself on load, it's done dynamically on demand when a command set is triggered. Until it has been triggered the side pane nor Moi's main code does not yet know anything about the contents of it.

So enumerating *.js files in the commands folder may be a better method.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
 
Show messages: All  1  2-5