X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



3077 Rate this article:
No rating

How to add an OS native menubar to a top-level base widget?

With IDL it is possible to create an OS native drop down menu bar within a widget dialog. These menu bars give the widget application more of a native look and feel across IDL’s supported platforms. 

Discussion

Windows and UNIX Platforms

To create a menubar at the top of the widget dialog, set the MBAR keyword equal to a named variable when creating the top-level base widget. The menubar is itself a special kind of base widget that can only have WIDGET_BUTTON or CW_PDMENU widgets as children. Upon return, the named variable contains the widget ID of the new menubar base. This widget ID will then be used to as the parent widget ID for WIDGET_BUTTON and/or CW_PDMENU widgets that make up the menubar. The code in the Example Code section below demonstrates how to add such a menubar to a widget. The widget creation commands first create a top-level base (wTLB) with a menubar (mbar), then populates the menubar with two WIDGET_BUTTON widgets (wFile_menu and wHelp_menu) that will form the root buttons of the drop down menus. Then a couple of submenu buttons are added to each of the root buttons. Note, CW_PDMENU could also have been used to construct the pulldown menu.

For additional information, please refer to WIDGET_BASE in the IDL documentation.

Example:

;Create a top-level base and set the MBAR keyword
;   equal to a named variable.
wTLB = WIDGET_BASE(TITLE = 'Example', MBAR=mbar)
  
   ;Add the first button ("File") to the menubar
   ;   Notice that the parent of the first button
   ;   is the mbar variable
   wFile_menu = WIDGET_BUTTON(mbar, VALUE='File', /MENU)
      ;Add sub-buttons to the "File" menu button
      wFile_bttn1=WIDGET_BUTTON(wFile_menu, VALUE='File Sub 1')
      wFile_bttn2=WIDGET_BUTTON(wFile_menu, VALUE='File Sub 2')
  
   ;Add another button to the menubar
   wHelp_menu = WIDGET_BUTTON(mbar, VALUE='Help', /MENU)
      ;Add a sub-button to the second menubar button
      wHelp_bttn1=WIDGET_BUTTON(wHelp_menu, VALUE='Help Sub 1')
      wHelp_bttn2=WIDGET_BUTTON(wHelp_menu, VALUE='Help Sub 2')
  
   ;Add a text widget to the top-level base
   wTextBox = WIDGET_TEXT(wTLB, VALUE = "Sample text.", $
            XSIZE = 30, YSIZE=10, /EDITABLE)

;Realize the widget
WIDGET_CONTROL, wTLB, /REALIZE

;Continue your code...
Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »