ban2/png

tutor/gif
Home

cell/gif

Adding a Colour menu

cell/gif
1/gif Add Colour Menu

resf/gif

Add a colour menu to the resfile for Example 2.3.a and attach it as the window's popup menu.

att/gif

When run, the application will popup a Colour menu whenever the menu button is selected over the window.

win2/gif

2/gif Add a “Colour Menu” event-handler
Add the following event-handler to !RunImage
DEF PROCDealWith_ColourMenu(event,object,component)
CASE event OF
 WHEN ColourMenu_AboutToBeShown
 WHEN ColourMenu_HasBeenHidden
 WHEN ColourMenu_Selection
      PROCColourMenu_GetColour(object,Colour)
ENDCASE
ENDPROC
win3/gifThe Toolbox method

PROCColourMenu_GetColour

is used to obtain the colour selected. This is then used in subsequent calls of the event-handler DealWith_WindowRedraw. E.g. when the menu is removed, the Wimp reports a window redraw event for the portion of the work area formerly covered by the menu.
3/gif Forcing a redraw
Since the colour menu is attached to the window, the window is the parent of the menu and its object id can be obtained using the method PROCToolbox_GetParent. Once the window's id is known, its extent can be found and a command to redraw issued:

DEF PROCDealWith_ColourMenu(event,object,component)
LOCAL window,x,y,X,Y
CASE event OF
 WHEN ColourMenu_AboutToBeShown
 WHEN ColourMenu_HasBeenHidden
 WHEN ColourMenu_Selection
      PROCColourMenu_GetColour(object,Colour)
      PROCToolbox_GetParent(object,window,component)
      PROCWindow_GetExtent(window,x,y,X,Y)
      PROCWindow_ForceRedraw(window,x,y,X,Y)
ENDPROC
4/gif Worked solution