General XMetaL Discussion

  • Fendor

    Disable "Insert" Menu

    Participants 2
    Replies 3
    Last Activity 13 years, 4 months ago

    Hi,

    I need to temporarily inhibit all subitems of the “Insert ” menu.
    According to manuals we can only disable User defined controls while the built-in menu items cannot be disabled.

    Returns the control’s current enable state or sets the new enable state. For built-in controls, setting Enabled to True causes the application to determine its state, but setting it to False forces it to be disabled. Enabled applies only to user-defined controls.

    as there any alternatives to do that either by hiding the menu item or by overriding it's handler?

    Reply

    Derek Read

    Reply to: Disable "Insert" Menu

    The documentation is incorrect because this feature has not been completed. The Enabled property currently only affects “custom” menu items (those added manually using the “Customize” feature for toolbars and menus, or via script). It does not disable built-in functions (yet).

    Reply

    Derek Read

    Reply to: Disable "Insert" Menu

    A quick workaround that might get you what you need is the following:

    Remove the entire Insert menu from the “Menu bar” (main menu):
    [code]//XMetaL Script Language JSCRIPT:
    var commandBars = Application.CommandBars;
    var menuBar = commandBars.item(“Menu bar”);
    var insertMenu = menuBar.Controls.item(4);
    insertMenu.Delete();
    [/code]

    Restore the “Menu bar” (put the Insert menu back):
    [code]//XMetaL Script Language JSCRIPT:
    var commandBars = Application.CommandBars;
    var menuBar = commandBars.item(“Menu bar”);
    menuBar.Reset();[/code]

    Depending on when the first portion of this script is run you may wish to add an if/then check after selecting menuBar.Controls.item(4) to make sure that item is in fact the Insert menu before removing it. You could do that with the DescriptionText property.

    Note that these scripts will affect either the default menu (no documents are open) or the menu for the current document customization (a document is active).

    Reply

    Fendor

    Reply to: Disable "Insert" Menu

    Thanx!

    Reply

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

Lost Your Password?

Products
Downloads
Support