FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

DRAWING

Define a procedure to be called while the mouse button is down


You can define an "Action" procedure to be called repeatedly for as long as the button is being held down. The steps are as follows:

1. Write your "Action" procedure within an ENTERPROC...EXITPROC block. The procedure must take two parameters: a long integer (which will receive the button's "control record handle") and a short integer (which will receive the "part code" of the part of the button that the mouse is on). It should look like this:

"MyAction"
ENTERPROC (btnH&, partCode%)
[things to do while button is down]
EXITPROC

2. Create your button.

BUTTON _myButton, [etc., etc.]

3. Store the address of your action procedure into the contrlAction field of the button's control record.

buttonRecH& = BUTTON&(_myButton) 'Get the handle
buttonRecH&..contrlAction& = LINE "MyAction"

That's all there is to it! Here's a demo:

DIM rect.8
WINDOW 1
CALL SETRECT(rect,100,100,120,120)
CALL FRAMERECT(rect)
CALL INSETRECT(rect,1,1)
BUTTON 1,_activeBtn, "Click & Hold", (10,10)-(150,30)
h& = BUTTON&(1)
h&..contrlAction& = LINE "MyAction"
DO
  HANDLEEVENTS
UNTIL _false
END
"MyAction"
ENTERPROC(btnH&, partCode%)
'(Drag away from button to see red)
  IF partCode% = 0 THEN COLOR = _zRed ELSE COLOR = _zBlack
  LONG IF FN TICKCOUNT MOD 20 > 10
    CALL PAINTRECT(rect)
  XELSE
    CALL ERASERECT(rect)
  END IF
EXITPROC

Rick