EZText:
Filter:
Classes | GUI > EZ-GUI

EZText : EZGui : Object

Wrapper class for a label, a text field and a value
Source: EZText.sc

Description

EZText is a wrapper class which creates an (optional) StaticText, and a TextField. The value is displayed as a compileString in the text field for editing.

Some Important Issues Regarding EZText

If the parent is nil, then EZText will create its own Window. See EZGui for more options.

Class Methods

Creation / Class Methods

EZText.new(parent, bounds, label, action, initVal, initAction: false, labelWidth: 60, textWidth, labelHeight: 20, layout: 'horz', gap, margin)

Arguments:

parent

The parent view or window. If the parent is nil, then EZText will create its own Window, and place it conveniently on the screen if the bounds are a Point. If the bounds are a Rect, then the Rect determines the window bounds.

bounds

An instance of Rect or Point. Default value is 160@20.

label

The label. Default value is nil. If nil, then no StaticText is created.

action

A Function called when the value changes. The function is passed the EZText instance as its argument.

initVal

The value to initialize the EZText with.

initAction

A Boolean indicating whether the action function should be called when setting the initial value. The default is false.

labelWidth

Number of pixels width for the label. The default is 60. In the \horz layout, if you specify the textWidth, then the labelWidth is ignored and is set to the bounds.width - textWidth.

textWidth

Number of pixels width for the number box. The default is 45. In \vert layout, textWidth defaults to the bounds.width.

labelHeight

Default is 20.

layout

\vert, or \horz. The default is \horz; \vert is a two line version.

gap

A Point. By default, the view tries to get its parent's gap, otherwise it defaults to 2@2. Setting it overrides these.

margin

A Point. This will inset the bounds occupied by the subviews of view.

Discussion:

Example:

The contained views can be accessed via the EZText instance variables: labelView, textField.

Inherited class methods

Instance Methods

.textField

Returns the textField.

.action

.action = value

From superclass: EZGui

A Function to be evaluated when the value changes. Typical use is to type in a new value, and interpret it by hitting the evaluation shortcut. The first argument to the function will be the EZText.

.value

.value = inval

From superclass: EZGui

Gets/sets the value of the ezText. Does not perform the action.

Arguments:

inval

Any object.

.valueAction = val

From superclass: EZGui

Sets the value and performs the action.

Arguments:

val

Any object.

.doAction

From superclass: EZGui

Performs the action.

.enabled

.enabled = bool

From superclass: EZGui

Sets/gets whether the textfield is enabled.

Arguments:

bool

An instance of Boolean. Default is true.

Changing Appearance

.setColors(stringBackground, stringColor, textBackground, textStringColor, textNormalColor, textTypingColor, background)

Arguments:

stringBackground

An instance of Color. The background of the label and unit views.

stringColor

An instance of Color. The stringColor of the label and unit views.

textBackground

An instance of Color. The background of the textField.

textStringColor

An instance of Color. The stringColor of the textField.

textNormalColor

An instance of Color. The normalColor of the textField.

textTypingColor

An instance of Color. The typingColor of the textField.

background

An instance of Color. The background of the enclosing view.

.font = font

Set the Font used by all the views.

Arguments:

font

An instance of Font.

Inherited instance methods

Undocumented instance methods

.prSetViewParams

Examples