- When writing new applications, decompose the problem into sub-problems and write reusable compound widgets to implement them. In this way, you will build a collection of reusable widget solutions to general problems instead of hard-to-modify, monolithic programs.
- Use the GROUP_LEADER keyword to WIDGET_BASE to define the relationships between parts of your application. Group leadership/membership relationships make it easy to group widgets appropriately for iconization, layering, and destruction.
- Use the MBAR keyword to WIDGET_BASE to create application-specific menubars. Use keyboard focus events to track which widget menu options should affect.
- Use existing compound widgets when possible. In particular, use the CW_BGROUP and CW_PDMENU compound widgets to create menus. These functions are easier to use than writing the menu code directly, and your intent will be more quickly understood by others reading your code.
- The many advantages of the XMANAGER procedure dictate that all widget programs should use it. There are few if any reasons to call the WIDGET_EVENT procedure directly.
- Use CATCH to handle any unanticipated errors. The CATCH branch can free any pointers, pixmaps, logical units, etc., to which the calling routine will not have access, and restore IDL session-wide settings like color tables and system variables that were locally modified.
- It can be difficult to write 100% portable widget code that looks good on all platforms, so let IDL do the layout for you when possible. If all else fails, it is possible to use the value of the WIDGET_INFO function to execute special-case code for each platform's user interface toolkit. It is desirable, however, to avoid large-scale special-case programming because this makes maintenance of the finished program more difficult. See Portability Issues below for additional suggestions.
- Use the BITMAP keyword to WIDGET_BASE to add a custom icon to your base widget (Windows platform only).