Adding menu items to shortcut menu

Discussion in 'AutoCAD' started by Gilles Plante, Aug 19, 2003.

  1. Hi all,

    I thought it would be great to add menu items to the default shortcut menu
    in a VBA project.

    So I use the BeginShortcutMenuDefault and EndShortcutMenu events. Menu items
    appear and disapear as expected, except I get a side effect: one of the
    standard menu item is 'broken'. The Repeat item instead of displaying for
    example "Repeat CIRCLE", displays "Repeat %s". When my code is not active,
    everything is correct.

    Is it an AutoCAD bug, or is there something I am doing wrong ? Is there a
    workaround ?

    Thanks.

    Gilles Plante
     
    Gilles Plante, Aug 19, 2003
    #1
  2. Gilles,

    It appears that you may be violating one of the "Event handler rules"

    Gary

    From the VBADEV.pdf help file (Acad 2000):

    You can write data to any object in the database, except the object that
    issued the event

    Obviously any object causing an event to be triggered could still be open
    for use with AutoCAD and the operation currently in progress. Therefore,
    avoid writing any information to an object from an event handler for the
    same object. However, you can safely read information from the object
    triggering an event. For example, suppose you have a floor that is filled
    with tiles and you create an event handler attached to the border of the
    floor. If you change the size of the floor, the event handler will
    automatically
    add or subtract tiles to fill the new area. The event handler will be
    able to read the new area of the border, but it cannot attempt any changes
    on the border itself.
     
    Gary McMaster, Aug 20, 2003
    #2
  3. Gary,

    I know the rule you are talking about, but the menu is not an AutoCAD
    object. Menus are described in files and loaded in memory when AutoCAD is
    started.

    I have tried the same code with AutoCAD 2000i, 2002 and 2004, same results.

    Gilles
     
    Gilles Plante, Aug 20, 2003
    #3
  4. Isn't the "ShortcutMenu" object the object triggering this event? If so, you
    are trying to modify that object in one of your statements.

    Gary

    Private Sub AcadDocument_EndShortcutMenu(ShortcutMenu As IAcadPopupMenu)

    ShortcutMenu.Item(colMenuIt(I)).Delete
     
    Gary McMaster, Aug 20, 2003
    #4
  5. Gary,

    from the on line documentation:

    --------------

    BeginShortcutMenuDefault Event



    Triggered after the user right-clicks on the drawing window, and before the
    shortcut menu appears in default mode.

    <...>

    This event allows you to make changes to the shortcut menu before it is
    displayed. To make changes to the shortcut menu, edit the PopupMenu object
    that is passed in to your handler from the event. This same PopupMenu object
    is passed out as the current shortcut menu. Use the EndShortcutMenu event to
    perform any cleanup work on the shortcut menu.

    ---------------

    I am using the event for the purpose described. I think the answer lies in
    what is not told - the example as most of the time is useless.

    Gilles
     
    Gilles Plante, Aug 20, 2003
    #5
  6. from the on line documentation:

    In that case ... I guess event "mis-handling" is not involved.

    Sorry for the dead end replies.

    Gary
     
    Gary McMaster, Aug 20, 2003
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.