Home Forums General XMetaL Discussion Add new button to toolbar Reply To: Add new button to toolbar

dcramer

Reply to: Add new button to toolbar

I'd started on some xslts to generate the add/remove toolbar changes a while back. I believe I had it working for the menus but hadn't added the toolbars yet. The idea is to set up your menus manually using the XMetaL GUI, then close XMetaL so it saves all that to a tbr file. Then you run this over your tbr file and it gives you the js you need to add to your mcr file. Why do this? Long ago I thought the right way to do it was to use xmetal to create the tbr file and push stuff out that way. Rather than manually code all the menu changes (I have a bunch) I figured I'd write an xslt (note this is an xslt 2.0 stylesheet, so you should use Saxon 9):

[code]

 

 
 
 
// Get the CommandBars object
var cmdBars = Application.CommandBars;
// Get a single command bar (the main menu bar)
var menuBar = cmdBars.item(“Menu bar”);
// Get all of the menu bar's controls (all of the menus)
var menuBarCtrls = menuBar.Controls;

var currentTopMenu;
var currentTopMenuCtrls;

 
 

['”]
'

 
currentTopMenu = menuBarCtrls.item();
currentTopMenuCtrls = currentTopMenu.Controls;

 

 

 

 
currentTop
for (i=1;i<=MenuCtrls.count; i++) {
if(MenuCtrls.item(i).Caption == ''){ MenuCtrls.item(i).Delete(); }
}
newSubItem = MenuCtrls.Add(5,1,);
newSubItem.Caption = ““;
newSubItem.BeginGroup = ;
newSubItem.OnAction = ““;
newSubItem.Enabled = true;
 

 
currentTop
for (i=1;i<=MenuCtrls.count; i++) {
if(MenuCtrls.item(i).Caption == ''){ MenuCtrls.item(i).Delete(); }
}
newSubItem = MenuCtrls.Add(5,1,);
newSubItem.Caption = '';

newSubItem.BeginGroup = ;
newSubItem.OnAction = ““;
newSubItemMenuCtrls = newSubItem.Controls;

  newSubItem

 

[/code]

Reply

Products
Downloads
Support