General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion After adding items to a builtin menu, the items remain disabled

  • dcramer

    After adding items to a builtin menu, the items remain disabled

    Participants 1
    Replies 2
    Last Activity 12 years, 12 months ago

    Using 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,
    David

    Reply

    XMetaLOldTimer

    Reply to: After adding items to a builtin menu, the items remain disabled

    Please 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 file

    On_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_Complete

    Regards,
    Addam

    P.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.

    Reply

    dcramer

    Reply to: After adding items to a builtin menu, the items remain disabled

    That must be it. For testing, I was doing it as part of a normal macro. I'll move them to one of those macros and try again.

    Thanks,
    David

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support