User Tools

Site Tools


weblogo:properties:control

Controls

Controls are widgets that provide the standard operating system widgets like buttons, edit fields, and the like. Logo supports a number of standard controls. All controls contain the same set of properties as all widgets, plus a few extra properties.

By default, a control has a transparent background, except for buttons. You can change a control's background color and opacity by setting its BACKGROUND property.

All controls inherit the properties of the WIDGET object. They share this common set of properties:

BACKGROUND

Controls the background color of a control.

Description

BACKGROUND controls the background color of the control. By default, it is set to White. You cannot set the background color of pushbuttons.

Example

GPROP "MY.CONTROL "BACKGROUND
Result: [255 255 255 1]

COLOR

Controls the text color of a control.

Description

COLOR controls the text color of the control. The color depends on the type of control, and not every control honors the setting of this property.

The GRID control's COLOR property controls the color of the grid's cell borders, which are dotted lines. Set the color to [0 0 0 0] or any other color with an alpha value of 0 to make the cell borders invisible. Use the grid's BORDER property to change the outer border color.

Example

GPROP "MY.CONTROL "COLOR
Result: [0 0 0 1]

SELECTED

Changes the input focus to the control.

Description

SELECTED reads always as FALSE. Set it to TRUE to switch the input focus to the control.

Example

PPROP "EDIT "SELECTED TRUE

TEXT

Gets or sets the text of the control.

Description

The TEXT property sets the text of the control. This may be the label, the text to display, or the text to select for list boxes or popups. Reading the property outputs the current text, the label, or the selected text for list boxes and popups.

Example

PPROP "BUTTON "TEXT "OK

TEXTALIGN

Controls the alignment of the text within the control.

Description

Setting this property causes any content to be aligned horizontally. Legal values are LEFT, CENTER and RIGHT. Note that some controls like the GRID control ignore the alignment setting.

Example

PPROP "BUTTON "TEXTALIGN "LEFT

Push buttons (BUTTON)

A pushbutton is a clickable widget that acts like a button.

It contains all WIDGET and CONTROL properties. The TEXT property sets the button label, and the contents of the RUN property are executed if the button is clicked.

Check boxes (CHECKBOX)

A checkbox is a box with a check mark that can be turned on and off.

It contains all WIDGET and CONTROL properties. The TEXT property sets the checkbox label, and the contents of the RUN property are executed if the checkbox's check mark changes.

STATE

Gets or sets the Selected state of a check box or radio button.

Description

STATE controls the state of a check box or a radio button. Setting STATE to TRUE sets the check mark or the radio button.

Example

PPROP "CHECKBOX "STATE TRUE

Radio Buttons (RADIOBUTTON)

A radio button is a box with a round clickable area that can be turned on. Usually, radio buttons are grouped together, and only one of the buttons should be turned on. A well-written Logo program should, therefore, turn off all other radio buttons in a group if a button in this group has been turned on. Set a radio button’s STATE property to FALSE to turn it off. A radio button contains the same set of properties as a CHECKBOX widget.

Text fields (STATICTEXT)

A text field (or label) box that displays non-editable text. It contains all WIDGET and CONTROL properties. It can be clicked, and its text can be set.

AUTOSCROLL

Gets or sets a vertical scroll bar.

Description

If AUTOSCROLL set to TRUE, a vertical scroll bar appears if the text is too long to display in the available space.

Example

PPROP "TEXT "AUTOSCROLL TRUE

Edit Boxes (EDITBOX)

An edit box is a box with a single line of editable text. It contains all WIDGET and CONTROL properties, plus a few extra properties that are listed below. Logo executes the contents of the RUN property every time the text changes; it cannot be clicked to execute the RUN property.

Read-Write Properties

FILTER

Gets or sets the edit field's input filter.

Description

The FILTER property can be set to a list of characters that the user is allowed to enter. Characters other than defined in the filter are ignored.

Example

PPROP "MY.EDIT "FILTER "1234567890

LIMIT

Limits the number of character that a user can enter into an edit box.

Description

The LIMIT property limits the number of characters that a user can enter into a text box. The value can be any number between 1 and 1000; initially, this value is 1000.

Example

; a zip code entry field
PPROP "MY.ZIPCODE "LIMIT 5
PPROP "MY.ZIPCODE "FILTER "1234567890

MODIFIED

Reports whether the contents of an edit box have been modified.

Description

Whenever the user changes the text of an edit box, its MODIFIED property is set to TRUE. A user can set the property to FALSE to reset that flag.

Example

PPROP "MY.EDIT "MODIFIED FALSE

PLACEHOLDER

Gets or sets the edit field's placeholder text.

Description

The PLACEHOLDER gets or sets a ghost text that vanishes once the user starts typing. It should indicate what the user should type into the text box.

Example

PPROP "MY.EDIT "PLACEHOLDER "|Please enter your name|

List Boxes (LISTBOX)

A list box is a box that displays a number of choices. The user can select a choice with a mouse click. You can select an entry by setting its INDEX property to the zero-based index. It contains all WIDGET and CONTROL properties, plus a few extra properties that are listed below. Logo executes the contents of the RUN property every time the selection changes; it cannot be clicked to execute the RUN property.

The TEXT property reports the text of the currently selected item, or the empty word if no item is selected. Setting the property causes the entry with the given text to be elected. If there is no match for the text, the selection is removed.

List box entries are not sorted.

APPEND

Appends one or more items to the list box.

Syntax

ASK listbox-name [APPEND item]
ASK listbox-name [APPEND [item-1 item-2 ...]]

Description

APPEND appends one or more items to the list box. If the input to APPEND is a list, each list element is treated as a separate list box entry. Outputs the index of the last inserted item.

Example

ASK "LISTBOX [APPEND [ONE TWO THREE]]

CLEAR

Erases the contents of the list box.

Syntax

ASK listbox-name [CLEAR]

Description

CLEAR erases the contents of the list box.

Example

ASK "LISTBOX [CLEAR]

FIND

Finds a list box item.

Syntax

ASK listbox-name [FIND text]

Description

FIND searches the text in the list box and outputs the index of the item if the text is found (case insensitive). If the text cannot be found, FIND outputs -1.

Example

ASK "LISTBOX [FIND "TWO]
Result: 1

INDEX

Controls the index of a selected list box item.

Description

INDEX reports zero-based index of the currently selected item of a list box. The value is -1 if no item has been selected. Setting the INDEX property causes the item with the given item to be selected, or all items to be deselected if the input value is -1.

Example

GPROP "LISTBOX "INDEX
Result: 2

INSERT

Inserts one or more items into a list box.

Syntax

ASK listbox-name [INSERT item]
ASK listbox-name [INSERT [item-1 item2 ...]]

Description

INSERT inserts one or more items in front of the currently selected item. If no item is selected, the procedure appends the item(s) to the list box contents. If the input to INSERT is a list, each list element is treated as a separate list box entry. Outputs the index of the last inserted item.

Example

PPROP "LISTBOX "INDEX 1
ASK "LISTBOX [INSERT "ONE.POINT.FIVE]

ITEM

Outputs a list box item by index.

Syntax

ASK listbox-name [ITEM number]

Description

ITEM outputs the list box item at position index (0-based). If the index is out of range, ITEM outputs the empty word.

Example

ASK "LISTBOX [ITEM 0]
Result: ONE

ITEMCOUNT

Reports the number of list box items.

Description

ITEMCOUNT reports the number of list box items. The property is read-only.

Example

GPROP "LISTBOX "ITEMCOUNT
Result: 0

ITEMS

Controls the contents of the listbox.

Syntax

GPROP listbox "ITEMS

Description

The ITEMS property outputs a list of all items in the list box. Setting this property sets all items in the listbox.

Example

PPROP "LISTBOX "ITEMS [ONE TWO THREE]
ASK "LISTBOX [APPEND "FOUR]
GPROP "LISTBOX "ITEMS
Result: [ONE TWO THREE FOUR]

REMOVE

Removes a list box item.

Syntax

ASK listbox-name [REMOVE number]

Description

REMOVE removes the item at the given index position. If the index is out of range, the procedure does nothing.

Example

ASK "LISTBOX [REMOVE 0]

REPLACE

Replace a listbox item text.

Syntax

ASK listbox-name [REPLACE new-text]

Description

REPLACE replaces the currently selected item with another text. If the list box is sorted, the items may be re-sorted. The item remains selected. If no item is selected, the procedure does nothing.

Example

ASK "LISTBOX [REPLACE "OK]

Popups (POPUP)

A popup is a widget that displays a single choice. When clicked, a list drops down (or pops up) to display all possible choices. Popups are functionally identical to list boxes. Therefore, a popup contains the same properties as a list box.

A POPUP widget is also a LISTBOX widget.

Sliders (SLIDER)

A slider has a thumb that you can drag to alter a value. Sliders have a minimum and a maximum value. It contains all WIDGET and CONTROL properties, plus a few extra properties that are listed below. Logo executes the contents of the RUN property every time the selection changes; a simple click does not execute the RUN property. Please note that when you drag the slider's handle, the contents of the RUN property may be executed very often, because the slider's value changes rapidly.

Note: This control replaces the Terrapin Logo SCROLLBAR control. The SMALLINC and LARGEINC properties have been merged into the INCREMENT property. The VERTICAL property used to make the scrollbar vertical. It has been removed, because you can rotate a control to any angle with the turtle commands RIGHT, LEFT or SETHEADING.

INCREMENT

Controls the increment value when the slider is dragged.

Description

INCREMENT gets or sets the value that Logo adds to the slider value when the slider is dragged one pixel.

Example

GPROP "SLIDER "INCREMENT
Result: 1

MAXIMUM

Controls the maximum value of the slider.

Description

MAXIMUM gets or sets the maximum value that the slider can be set to.

Example

GPROP "SLIDER "MAXIMUM
Result: 100

MINIMUM

Controls the minimum value of the slider.

Description

MINIMUM gets or sets the minimum value that the slider can be set to.

Example

GPROP "SLIDER "MINIMUM
Result: 0

VALUE

Sets or gets the current value of a slider.

Description

VAUE reports or sets the current value of the slider. If setting a value, the slider adjusts it so it is between MINIMUM and MAXIMUM, and sets the slider's knob accordingly.

Example

GPROP "SLIDER "VALUE
Result: 50

Grids (GRID)

A grid is a grid of cells that can contain text or widgets. Please refer to the Grids page for more information.

The grid's COLOR property controls the color of the grid's cell borders, which are dotted lines. Set the color to [0 0 0 0] or any other color with an alpha value of 0 to make the cell borders invisible. Use the grid's BORDER property to change the outer border color.

CELLSIZE

Controls the size of all table cells.

Description

This property sets the minimum size of all grid cells in pixels. The first list item is the width, and the second item is the height of each cell. If you use values that are ⇐ 0, the table aligns it cell width or height to match the widest item in a column, or the tallest item in a row. This is the default.

Example

GPROP "GRID "CELLSIZE
Result: [-1 -1]

COLOR

Controls the grid's cell border color.

Description

The GRID control's COLOR property controls the color of the grid's cell borders, which are dotted lines. Set the color to [0 0 0 0] or any other color with an alpha value of 0 to make the cell borders invisible. Use the grid's BORDER property to change the outer border color.

Example

PPROP "GRID "COLOR [0 0 0 0]

COLUMNS

Controls the number of columns of a grid.

Description

COLUMNS returns or sets the number of grid columns. Note that if you set the value, the grid is recreated, causing the contents to get lost, and any widgets to be destroyed.

To set both the number of rows and columns, use SETGRIDDIMS.

Example

GPROP "GRID "COLUMNS
Result: 3

ROWS

Gets or sets the number of rows in a grid.

Description

Returns or sets the number of grid rows. Note that if you set the value, the grid is recreated, causing the contents to get lost, and any widgets to be destroyed.

To set both the number of rows and columns, use SETGRIDDIMS.

Example

GPROP "GRID "ROWS
Result: 3

Videos (VIDEO)

The VIDEO control displays a video from a streaming site such as Vimeo or YouTube. It contains all WIDGET and CONTROL properties. The LINK property accepts a special video link; please note that a URL is case sensitive! The property recognizes several video streaming services as special URLs. Often, the URLs to view a video are complex beasts to type in. If you know the ID of your video, you can use the name of the video service, a colon, and the ID of that video.

An example: If you click a YouTube video, its URL (displayed in the browser's address bar could be, for example:

https://www.youtube.com/watch?v=ZJaSQgsDQ1w

The text “ZJaSQgsDQ1w” is the video ID. To watch this video, use this command (assuming that the name of your control is WEBPAGE):

PPROP "VIDEO "LINK "|youtube:ZJaSQgsDQ1w|

The property recognizes these video service names: vimeo, ustream, youtube, viddler, slideshare, dailymotion, bambuser, metacafe, bliptv, break, msoffice, archiveorg, and niconico.

Gets or sets the video link of the video to display.

Description

Returns or sets the video link of the video to be displayed.

Example

PPROP "VIDEO "LINK "|youtube:ZJaSQgsDQ1w|

Webcams (WEBCAM)

The WEBCAM control displays the video feed of an attached webcam. Initially, Logo picks the first camera it finds and displays that video feed.

CAMERA

Controls which camera is active.

Description

CAMERA selects the camera whose feed Logo should display. Its input is either a number between 1 and the number of cameras attached to the computer, or the case-insensitive start of a camera name as returned by the CAMERAS property.

CAMERA also accepts a two-element list, where the first element is the camera name or number, and the second element is the desired width of the camera resolution in pixels. Many cameras support different resolutions, and Logo tries to match the supplied value as closely to the next available resolution as possible.

Example

^
; selects the first camera
PPROP "WEBCAM "CAMERA 1
; Selects the first camera whose name starts with "Live"
PPROP "WEBCAM "CAMERA "LIVE
; Select camera 2 with a desired resolution width of 1280 pixels
PPROP "WEBCAM "CAMERA [2 1280]

CAMERAS

Outputs a list of camera names.

Description

CAMERAS outputs a list of cameras attached to the computer. You can use the name of a camera to select it with the CAMERA property.

Example

GPROP "WEBCAM "CAMERAS
Result: [|FaceTime HD Camera| |USB Microscope|]

RESOLUTION

Outputs a two-element list of the current camera resolution.

Description

RESOLUTION outputs a two-element list describing the resolution of the currently selected camera. The first element is the width and the second element is the height, both measured in pixels.

If no camera is attached, both values are 0.

Example

GPROP "WEBCAM "RESOLUTION
Result: [640 480]

TITLE

Outputs the name of the currently attached camera.

Description

The TITLE property outputs the name of the currently attached camera. If no camera is attached, it outputs the empty word.

Example

GPROP "WEBCAM "TITLE
Result: USB Microscope

Web pages (WEBPAGE)

The WEBPAGE control lets you display a web page inside a control. Please note that many web sites like e.g. Google do not allow their contents to be displayed inside an embedded control; in that case, the control remains blank if you load the page.

It contains all WIDGET and CONTROL properties. The LINK property accepts the URL of a web page; please note that a URL is case sensitive!

LINK

Gets or sets the URL of the page to display.

Description

Returns or sets the URL of the web page to be displayed. Please note that many web sites like e.g. Google do not allow their contents to be displayed inside an embedded control; in that case, the control remains blank if you load the page.

Example

PPROP "WEBPAGE "LINK "|https://doc.terrapinlogo.com|
weblogo/properties/control.txt · Last modified: 2018/09/13 05:07 by michael