Text Box - Maple Help

Maplets[Elements]

 TextBox
 define a text box for input or output

 Calling Sequence TextBox(opts) TextBox[refID](opts)

Parameters

 opts - equation(s) of the form option=value where option is one of background, cursor, editable, enabled, focus, font, foreground, height, onchange, popupmenu, reference, tooltip, value, visible, width, or wrapped; specify options for the TextBox element refID - name or string; reference to the element

Description

 • The TextBox window body element defines a text box for input or output in a Maplet application.

 • The TextBox element features can be modified by using options.  To simplify specifying options in the Maplets package, certain options and contents can be set without using an equation. The following table lists elements, symbols, and types (in the left column) and the corresponding option or content (in the right column) to which inputs of this type are, by default, assigned.

 Elements, Symbols, or Types Assumed Option or Content Font element font option range of positive integers height and width options, respectively PopupMenu element popupmenu option refID reference option string or symbol value option

 • A TextBox element can contain Action or command elements to specify the onchange option, a Font element to specify the font option, and a PopupMenu element to specify the popupmenu option.
 • A TextBox element can be contained in a Maplet or BoxLayout element, or Maplet element in a nested list representing a box layout.
 • If the text in a TextBox exceeds the size of the box, a vertical scroll bar is automatically displayed.
 • The following table describes the control and use of the TextBox element options.
 An x in the I column indicates that the option can be initialized, that is, specified in the calling sequence (element definition).
 An x in the R column indicates that the option is required in the calling sequence.
 An x in the G column indicates that the option can be read, that is, retrieved by using the Get tool.
 An x in the S column indicates that the option can be written, that is, set by using the SetOption element or the Set tool.

 Option I R G S append* x appendline* x background x x x cursor x x x editable x x x enabled x x x focus x font x x x foreground x x x height x x x onchange x popupmenu x reference x tooltip x x x value x x x visible x x x width x x x wrapped x x x

 * append appends to the end of the text in the text box. Its syntax is refID(append)="text", where refID is a reference to the text box.
 * appendline appends to the end of the text in the text box, then adds a new line. Its syntax is refID(appendline)="text", where refID is a reference to the text box.
 • The opts argument can contain one or more of the following equations that set Maplet application options.
 background = color
 The color of the highlights of the text box.  This can be a recognized color name, an RGB color structure, or a string of the form "#RRGGBB" where each pair is a two-digit hexadecimal number.
 cursor = nonnegint
 The position of the cursor in the text box, where the position at the start of the text box before all text is assigned as zero. For multi-line text, a newline counts as a single character. Setting to any value larger than the number of characters in the text box positions the cursor at the end of the text.
 editable = true or false
 Whether the text box can be edited by the user. This option should be set to false for output boxes. If editable = false, the text box is not editable, independent of the setting of the editable option. By default, the value is true.
 enabled = true or false
 Whether a text box can be highlighted.  If enabled is set to false, the text box is dimmed, and any action associated with it cannot be initiated.  By default, the value is true.
 focus = true
 Setting this to true causes the text box to obtain focus for the Maplet application.
 font = Font element or reference to a Font element (name or string)
 The text font in the text box.
 foreground = color
 The foreground color of the text box.
 height = posint
 The text box height in characters.  The default height is $1$ character.
 onchange = Action or command element, or reference to an Action element (name or string)
 The action that occurs when the user changes the value of the text box and makes the text box lose focus. The action does not occur when the user presses ENTER.
 The popup menu or reference to a popup menu for the text box.  The default entries for any popup menu are Cut, Copy, Paste, Delete, and Select All when the option editable is true and Copy and Select All when the option editable is false.  Any entries specified by this option are appended to the default entries.
 reference = name or string
 A reference to the TextBox element.
 If the reference is specified by both an index, for example, TextBox[refID], and a reference in the calling sequence, the index reference takes precedence.
 tooltip = string or symbol
 The text that appears in the tooltip help window.
 value = string or symbol
 The initial value of the text box. By default, the value is empty.
 visible = true or false
 Whether the text box is visible to the user.  By default, the value is true.
 width = posint
 The text box width in characters.  The default width is $20$ characters.
 wrapped = true or false
 Whether the content of the text box wraps to the next line. By default, the value is true.

Examples

A Maplet application that requires the user to enter text. Then the text is split into its individual words.

 > $\mathrm{with}\left(\mathrm{Maplets}\left[\mathrm{Elements}\right]\right):$
 > $\mathrm{maplet}≔\mathrm{Maplet}\left(\left[\left["Enter some text:",\mathrm{BoxCell}\left(\mathrm{TextBox}\left['\mathrm{IB1}'\right]\left(3..30\right)\right)\right],\left[\mathrm{Button}\left("OK",\mathrm{Shutdown}\left(\left['\mathrm{IB1}'\right]\right)\right),\mathrm{Button}\left("Cancel",\mathrm{Shutdown}\left(\right)\right)\right]\right]\right):$
 > $\mathrm{result}≔\mathrm{Maplets}\left[\mathrm{Display}\right]\left(\mathrm{maplet}\right)$
 > $\mathrm{if}\left(\mathrm{type}\left(\mathrm{result},\left['\mathrm{string}'\right]\right),\mathrm{StringTools}\left[\mathrm{Split}\right]\left(\mathrm{result}\left[1\right]\right),\mathrm{NULL}\right)$

This Maplet application uses the Set function to append new lines to the text box.

 > G:=proc() Maplets:-Tools:-Set('TB1' ('appendline') = "and more") end proc:
 > $\mathrm{with}\left(\mathrm{Maplets}\left[\mathrm{Elements}\right]\right):$
 > $\mathrm{maplet2}≔\mathrm{Maplet}\left(\left[\left[\mathrm{TextBox}\left['\mathrm{TB1}'\right]\left("Some text"\right),\mathrm{Button}\left("Append",\mathrm{Action}\left(\mathrm{Evaluate}\left('\mathrm{function}'='G\left(\right)'\right)\right)\right),\mathrm{Button}\left("Close",\mathrm{Shutdown}\left(\right)\right)\right]\right]\right):$
 > $\mathrm{Maplets}\left[\mathrm{Display}\right]\left(\mathrm{maplet2}\right)$