CREATE FLOATMENU Example


Example:

 

*

 

 

.Objects and Variables Required

.

 

 

FLOATL

FLOATMENU

// Left FLOATMENU

FLOATR

FLOATMENU

// Right FLOATMENU

REGION

MREGION

// Mouse Region

.

 

 

RESULT

FORM

9 // Result Variable

TPOS

FORM

4 // Mouse Vertical Position

LPOS

FORM

4 // Mouse Horizontal Position

DIGIT9

FORM

1 // Mouse Button Indicator

*

 

 

.Work in Pixel Mode

.

 

 

  

SETMODE

*PIXEL=ON

*

 

 

.Create the Left Mouse Button Floatmenu

.

 

 

  

CREATE

FLOATL=2:2:2:25:

  

  

";)Editor;)Compiler;De&bugger"

*

 

 

.Create the Right Mouse Button Floatmenu

.

 

 

  

CREATE

FLOATR=2:2:2:25:

  

  

"a;Cut;Copy;Paste;-;Select All":

  

  

RIGHTBUTTON

*

 

 

. Create a Mouse Region to Cover Part of the Window.

.

 

 

  

CREATE

REGION=0:250:0:300

  

ACTIVATE

REGION,REGIONR,RESULT

*

 

 

.Wait for an Event to Occur

.

 

 

  

LOOP

 

  

  EVENTWAIT

 

  

REPEAT

 

.

 

 

. This action routine processes events for

. the MREGION object. The routine determines

. whether the left or right button was used

. and the vertical and horizontal coordinates of

. the cursor. This information positions

. the FLOATMENUs to the point of the mouse click.

.

 

 

REGIONR

 

 

  

MOVE

RESULT,TPOS // Vertical Position

  

CALC

LPOS=RESULT/10000 // Hor Position

  

CALC

DIGIT9=RESULT/100000000 // 9th digit

.

 

 

  

SETPROP

FLOATL,TOP=TPOS,LEFT=LPOS

  

SETPROP

FLOATR,TOP=TPOS,LEFT=LPOS

*

 

 

. When the value of DIGIT9 is 0 or 2,

. the left mouse button was used. Otherwise,

. the right mouse button was used.

.

 

 

  

IF

( DIGIT9 = 0 |DIGIT9 = 2 )

  

 ACTIVATE

 FLOATL,MENUR,RESULT

  

ELSE

 

  

 ACTIVATE

 FLOATR,MENUR,RESULT

  

ENDIF

 

  

RETURN

 

*

 

 

. This is the action routine for either

. FLOATMENU object. This routine simply shows

. the result value passed to the action routine.

.

 

 

MENUR

 

 

  

DISPLAY

*P1:22,"Item Selected:",RESULT

  

RETURN

 

 

 

This example creates two floating menus and a mouse region. When the left mouse button is clicked within the mouse region, the left floating menu is displayed. When the right mouse button is clicked, the right floating menu is displayed. The position of the mouse pointer at the time of the click positions the menus before activation. Once activated, selection of a menu item will result in the item number being displayed.

 

 



PL/B Language Reference CREATE EDITTEXT Example CREATE FONT Example