Using popup menus (The TrackPopup() method)


Popup menus can be used with the KCML Grid control and KCML Picture button controls. Popup menus are created in the menu editor within the KCML Forms designer. To display a popup menu the TrackPopup() method is used. This method requires row and column co-ordinates to specify where on the form the menu is to be displayed. Both the KCML Grid and KCML Picture button controls return the row and column co-ordinates of the last mouse click in the MouseX and MouseY properties when the Click() event handler is triggered (LeftClick(), and RightClick() for the grid control). These properties can then be used by the event handler to display a popup menu. Note that the MouseX and MouseY properties return the co-ordinates relative to the top left hand corner of the control, therefore the controls Left property should be added to MouseX and the Top property should be added to MouseY. For example, the following picture button Click() event handler displays a popup menu onto the picture button surface:

 - DEFEVENT Form1.picControl1.Click()
     .menu1.TrackPopup(..Mousex + ..Left, ..MouseY + ..Top))
   END EVENT