General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › After adding items to a builtin menu, the items remain disabled
-
dcramer March 29, 2010 at 3:25 pm
After adding items to a builtin menu, the items remain disabled
March 29, 2010 at 3:25 pmParticipants 1Replies 2Last Activity 12 years, 12 months agoUsing XMetaL 4.6. With the following in a test macro, when I run the macro it adds the cvs menu and two menu items to the file menu in the appropriate location. However, the menu items “cvs commit” and “open in wincvs” are disabled even though the macros exist. Note that if I add an entirely new top level menu and some menu items on it, everything is fine. I only have this problem when I add items to a builtin menu:
[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(1);
currentTopMenuCtrls = currentTopMenu.Controls;newSubItem = currentTopMenuCtrls.Add(5,1,8);
newSubItem.Caption = 'c&vs';newSubItem.BeginGroup = false;
newSubItem.OnAction = “”;
newSubItemMenuCtrls = newSubItem.Controls;newSubItem = newSubItemMenuCtrls.Add(5,1,1);
newSubItem.Caption = “c&vs commit”;
newSubItem.BeginGroup = true;
newSubItem.OnAction = “cvs commit”;
newSubItem.Enabled = true;
newSubItem = newSubItemMenuCtrls.Add(5,1,2);
newSubItem.Caption = “Open file in &Wincvs”;
newSubItem.BeginGroup = false;
newSubItem.OnAction = “open_document_wincvs”;
newSubItem.Enabled = true;
[/code]What am I doing wrong?
Thanks,
DavidXMetaLOldTimer April 14, 2010 at 9:35 pm
Reply to: After adding items to a builtin menu, the items remain disabled
April 14, 2010 at 9:35 pmPlease be sure that you only adjust menus and toolbars during one of the following event macros:
On_Default_CommandBars_Complete
– must be in Startup mcr file, called to modify global/built-in toolbars used across all document types
– macros bound via OnAction property assignment must also be inside the Startup mcr fileOn_CommandBars_Load_Complete
– can be in Startup or document-level mcr, called when toolbar is first loaded.
– Check Application.CommandBars.Name to determine if global/built-in or dtd-specific toolbar collection
– macros bound via OnAction property assignment must be inside corresponding mcr file with On_CommandBars_Load_CompleteRegards,
AddamP.S. The CommandBarControl.Enabled property doesn't effect enable/disable state property…it is a long standing bug. Instead, be sure to call Application.DisableMacro() during On_Update_UI if you need to grey out a menu item or toolbar button of your making.
-
AuthorPosts
- You must be logged in to reply to this topic.