Documentation for Win32lib v0.60.6
Table of Contents

Menus

Routines that deal with menu and menuitem handling.


  • func attachPopup(integer pId, object pMenus)   Associates one or more menus to a control as popup or context menus.
  • proc defineMenuRadioGroup( sequence ids)   Defines a set of menu items that form a radio-group
  • func getMenuPosn(integer id)   Get the zero-based relative position of a menu item.
  • func skipF10(integer NewValue)   Sets whether or not F10 sets focus on the menubar
  • func struct_MENUITEMINFO()   Returns the RAM address of an empty MENUITEMINFO structure

    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    attachPopup
    (integer pId, object pMenus)

    Associates one or more menus to a control as popup or context menus.

    Returns: SEQUENCE: Previously attached menus.

    Category: Menus

    This will cause the menu(s) supplied in pMenu to be linked to the control pId such that when the righthand mouse button is pressed, the menu will pop up next to the mouse pointer.
    You can have different menus popup depending on the combination of Ctrl and Shift keys you have pressed. You do this by supplying up to four menu ids in pMenu, one for no keys pressed, one for shift key, one for control key, and another for both shift and control keys pressed.

    Each value in pMenu is either a Menu id, 0, -1, or a sequence of the form {MenuId, XOffset, YOffset}.
    If a simple menu id, then this is the popup menu that will display when the user right-clicks in the control.
    If -1, then the corresponding current value is retained. Use this to skip over setting previous values of menu ids.
    If 0, then the corresponding menu id is cleared and the popup will not display.
    If a sequence, then the XOffset and YOffset are used to position the menu relative to the mouse pointer. The default values are -6 and -6 respectively. Use this when you need the menu to be shown is different position.

    First you need to define the menus and any handlers for them, then you can attach them to one or more controls.

    Example

          -- Define two menus.
          MenuOne = create(Menu, "One", MainWindow, 0, 0, 0,0, 0)
            M1_Item1 = create(MenuItem, "Item 1.1", MenuOne, 0, 0, 0,0, 0)
            M1_Item2 = create(MenuItem, "Item 1.2", MenuOne, 0, 0, 0,0, 0)
            M1_Item3 = create(MenuItem, "Item 1.3", MenuOne, 0, 0, 0,0, 0)
          MenuTwo = create(Menu, "Two", MainWindow, 0, 0, 0,0, 0)
            M2_Item1 = create(MenuItem, "Item 2.1", MenuTwo, 0, 0, 0,0, 0)
            M2_Item2 = create(MenuItem, "Item 2.2", MenuTwo, 0, 0, 0,0, 0)
            M2_Item3 = create(MenuItem, "Item 2.3", MenuTwo, 0, 0, 0,0, 0)
          setHandler(M1_Item1, w32HClick, routine_id("Click_Item11"))
          setHandler(M1_Item2, w32HClick, routine_id("Click_Item12"))
          setHandler(M1_Item3, w32HClick, routine_id("Click_Item13"))
          setHandler(M2_Item1, w32HClick, routine_id("Click_Item21"))
          setHandler(M2_Item2, w32HClick, routine_id("Click_Item22"))
          setHandler(M2_Item3, w32HClick, routine_id("Click_Item23"))
    

    -- Now attach popups for normal and ctrl keys prevMenus = attachPopup(SomeFld, {MenuOne, -- Normal (no keys) -1, -- ignore Shift -- Note the changed X-Y offsets. {MenuTwo,-20,-10} -- Ctrl key })

    See Also: defineMenuRadioGroup, getMenuPosn, skipF10, struct_MENUITEMINFO


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    defineMenuRadioGroup
    ( sequence ids)

    Defines a set of menu items that form a radio-group

    Category: Menus

    ids is a list of menuitems that form a logical group of items, in which only one can be marked witha 'radio-button' icon.
    This routine ensures that only one item from the group will be marked. Any that were previously marked will be 'turned off'

    Note 1. The items do not have to be in the same menu.
    Note 2. A given menu item can only be in one radio group.

    Example:

          -- set the current loudness level.
           defineMenuRadioGroup({miPianissimo, miPiano, piModerato,
                                 miForte, miFortissimo})
          . . .
           setCheck( miForte, w32True)
    

    See Also: attachPopup, getMenuPosn, skipF10, struct_MENUITEMINFO


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    getMenuPosn
    (integer id)

    Get the zero-based relative position of a menu item.

    Returns: INTEGER: Zero-Based Position of th emenu item

    Category: Menus

    id is the id of a menu item.

    Example

      integer pos
      pos = getMenuPosn(miSave)
    

    See Also: attachPopup, defineMenuRadioGroup, skipF10, struct_MENUITEMINFO


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    skipF10
    (integer NewValue)

    Sets whether or not F10 sets focus on the menubar

    Returns: Returns INTEGER: The current value of the flag.

    Category: Menus

    By default, the F10 key sets focus on the menubar. If NewValue is w32True, then the behaviour is changed so that the F10 key does not set focus on the menubar.

    Example:

          integer PrevF10Flag
          PrevF10Flag = skipF10( w32True )
    
    ---------------------------------------------------------------------------

    See Also: attachPopup, defineMenuRadioGroup, getMenuPosn, struct_MENUITEMINFO


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    struct_MENUITEMINFO
    ()

    Returns the RAM address of an empty MENUITEMINFO structure

    Category: Menus

    You are required to release this memory when you have finished with it.

    Example:

      atom hMII
      hMII = struct_MENUITEMINFO()
      . . .
      w32release_mem(hMII)
    

    See Also: attachPopup, defineMenuRadioGroup, getMenuPosn, skipF10