BUTTONCREATE

Synopsis
BUTTONCREATE parent name label xpos ypos width height callback
Description

Creates a button control. A button control lets the user trigger events. The only function of the button control is to run the callback instruction list when it is pressed.

The parent input is the name of the window that owns the new button. If no window or dialog with that name exists, then the FMSLogo screen window is used as the parent.

The name input identifies the new button and must be a unique word.

The label input is a word to write on the button.

The xpos input is the X coordinate where the upper-left corner of the new button is placed.

The ypos input is the Y coordinate where the upper-left corner of the new button is placed.

The width input is the width of the new button.

The height input is the height of the new button.

The callback input is an instruction list that is run whenever the user clicks on the button.

If the parent of the button is the FMSLogo screen window, then the xpos, ypos, width, and height inputs are all given in turtle coordinates. Otherwise, they are given in "dialog units", the origin is the upper-left corner of the parent, and Y values increase as you move down the screen.

Example

Create buttons in a new window:

WINDOWCREATE "main "mywindow "mytitle 0 0 100 100 []
BUTTONCREATE "mywindow "myleft "Left 25 25 25 25 [FORWARD 2 LEFT 1]
BUTTONCREATE "mywindow "myright "Right 50 25 25 25 [FORWARD 2 RIGHT 1]
Click left or right repeatedly and watch the turtle.
WINDOWDELETE "mywindow

Create buttons on the FMSLogo screen window:

BUTTONCREATE "main "myleft "Left 50 50 50 25 [FORWARD 2 LEFT 1]
BUTTONCREATE "main "myright "Right 100 50 50 25 [FORWARD 2 RIGHT 1]
Click left or right repeatedly and watch the turtle.
WINDOWDELETE "main

See Also
BUTTONUPDATE
BUTTONENABLE
BUTTONDELETE

SourceForge.net Logo