CreateButton(id,x1,y1,x2,y2)
Use this command to declare a button on your display. The button is defined by the coordinates x1:y1 to x2:y2. If the user moves the mouse over the button, Hollywood will Gosub() to the label with the name ONBUTTONOVER and the number you specified for the button. If the user clicks the button, Hollywood will jump to the label with the name ONBUTTONCLICK and the number of your button.
CreateButton(1,0,0,200,200)
CreateButton(2,201,0,400,200)
CreateKeyDown(1,"ESC")
While(quit=FALSE)
WaitEvent
Wend
End
Label(ONBUTTONOVER1)
Print("Mouse over button 1")
WhileMouseOn
Print("Mouse out of button 1")
Return
Label(ONBUTTONCLICK1)
Print("User clicked button 1")
WhileMouseDown
Print("User released left mouse button")
Return
Label(ONBUTTONRIGHTCLICK1) ; requires Hollywood 1.5
Print("User right-clicked button 1")
WhileRightMouseDown
Print("User released right mouse button")
Return
Label(ONBUTTONOVER2)
Print("Mouse over button 2")
WhileMouseOn
Print("Mouse out of button 2")
Return
Label(ONBUTTONCLICK2)
Print("User clicked button 2")
WhileMouseDown
Print("User released left mouse button")
Return
Label(ONBUTTONRIGHTCLICK2)
Print("User right-clicked button 2") ; requires Hollywood 1.5
WhileRightMouseDown
Print("User released right mouse button")
Return
Label(ONKEYDOWN1)
quit=TRUE
Return
The above code creates two buttons on the screen and monitors
the user activity. If he presses the escape key, this demo
will quit. This example shows a good way of handling the user
input: It is advised that you use a loop like
While(quit=FALSE) WaitEvent Wend |
to handle the user's input. However you have to make sure that you always return to the WaitEvent() in the loop.