## 5.15 Numberentry widget

### 5.15.1 Description

A numberentry is a widget that displays a one-line text string and allows that string to be edited. The string can contains only integer values between a defined range. Small arrows allow the user to modify the value of the integer with the mouse. A portion of the entry may be selected as described below. If an entry is exporting its selection (see the `exportselection` option), then it will observe the standard X11 protocols for handling the selection. When an entry has the input focus it displays an insertion cursor to indicate where new characters will be inserted.

Number entries are capable of displaying strings that are too long to fit entirely within the widget's window. In this case, only a portion of the string will be displayed; commands described below may be used to change the view in the window. Entries use the standard `lrscrollbar` mechanism. They also support scanning, as described below.

Indices

Many of the widget methods for entry take one or more indices as arguments. An index specifies a particular character of the entry, in any of the following ways:

- integer : Specifies the character as a numerical index, where 0 corresponds to the first character in the string.

- `anchor` : Indicates the anchor point for the selection, which is set with the select from and select adjust widget commands.

- `'end'` : Indicates the character just after the last one in the entry's string. This is equivalent to specifying a numerical index equal to the length of the entry's string.

- `insert` : Indicates the character adjacent to and immediately following the insertion cursor.

- `'sel.first'` : Indicates the first character in the selection. It is an error to use this form if the selection isn't in the entry window.

- `'self.last'` : Indicates the character just after the last one in the selection. It is an error to use this form if the selection isn't in the entry window.

- `'@'#X` : In this form, `X` is treated as an x-coordinate in the entry's window; the character spanning that x-coordinate is used. For example, `'@'#0` indicates the left-most character in the window.

### 5.15.2 Parameters

- `1:I` : Specifies a positive integer value to display inside the widget. This parameter can be only used with the `set()` and `get()` methods.

- `init:I` : Specifies a positive integer value to display inside the widget. This parameter can be used at creation time only.

- `return:V` : When the window is closed, `V` is bound to the contents of the number entry. `V` must be a free variable.

- `background:C` or `bg:C` : Specifies the normal background color to use when displaying the widget. `C` must be a valid color (see Section 6.1).

- `borderwidth:P` : Specifies a non-negative value indicating the width of the 3-D border to draw around the outside of the widget (if such a border is being drawn; the `relief` option typically determines this). The value may also be used when drawing 3-D effects in the interior of the widget. `P` must be a valid screen distance (see Section 6.6).

- `cursor:A` : Specifies the mouse cursor to be used for the widget. `A` must be a valid cursor (see Section 6.7)

- `exportselection:B` : Specifies whether or not a selection in the widget should also be the X selection. If the selection is exported, then selecting in the widget deselects the current X selection, selecting outside the widget deselects any widget selection, and the widget will respond to selection retrieval requests when it has a selection. The default is usually for widgets to export selections. `B` must be a boolean.

- `font:F` : Specifies the font to use when drawing text inside the widget. This parameter can't be get at runtime, however it can be set. `F` must be a valid font (see Section 6.8)

- `foreground:C` or `fg:C` : Specifies the normal foreground color to use when displaying the widget. `C` must be a valid color (see Section 6.1)

- `highlightbackground:C` : Specifies the color to display in the traversal highlight region when the widget does not have the input focus. `C` must be a valid color (see Section 6.1)

- `highlightcolor:C` : Specifies the color to use for the traversal highlight rectangle that is drawn around the widget when it has the input focus. `C` must be a valid color (see Section 6.1)

- `highlightthickness:P` : Specifies a non-negative value indicating the width of the highlight rectangle to draw around the outside of the widget when it has the input focus. If the value is zero, no focus highlight is drawn around the widget. `P` must be a valid screen distance (see Section 6.6).

- `insertbackground:C` : Specifies the color to use as background in the area covered by the insertion cursor. This color will normally override either the normal background for the widget (or the selection background if the insertion cursor happens to fall in the selection). `C` must be a valid color (see Section 6.1).

- `insertborderwidth:P` : Specifies a non-negative value indicating the width of the 3-D border to draw around the insertion cursor. `P` must be a valid screen distance (see Section 6.6).

- `insertofftime:I` : Specifies a non-negative integer value indicating the number of milliseconds the insertion cursor should remain ``off'' in each blink cycle. If this option is zero then the cursor doesn't blink: it is on all the time. `I` must be a positive integer value.

- `insertontime:I` : Specifies a non-negative integer value indicating the number of milliseconds the insertion cursor should remain ``on'' in each blink cycle. `I` must be a positive integer value.

- `insertwidth:P` : Specifies a value indicating the total width of the insertion cursor. If a border has been specified for the insertion cursor (using the `insertborderwidth` option), the border will be drawn inside the width specified by the `insertwidth` option. `P` must be a valid screen distance (see Section 6.6).

- `justify:A` : When there are multiple lines of text displayed in a widget, this option determines how the lines line up with each other. Must be one of these atoms : one of `left`, `center`, or `right`. `left` means that the lines' left edges all line up, `center` means that the lines' centers are aligned, and `right` means that the lines' right edges line up.

- `relief:A` : Specifies the 3-D effect desired for the widget. Must be one of these atoms : `raised`, `sunken`, `flat`, `ridge`, `solid` or `groove`. The value indicates how the interior of the widget should appear relative to its exterior; for example, `raised` means the interior of the widget should appear to protrude from the screen, relative to the exterior of the widget.

- `selectbackground:C` : Specifies the background color to use when displaying selected items. `C` must be a valid color (see Section 6.1).

- `selectborderwidth:P` : pecifies a non-negative value indicating the width of the 3-D border to draw around selected items. `P` must be a valid screen distance (see Section 6.6).

- `selectforeground:C` : Specifies the foreground color to use when displaying selected items. `C` must be a valid color (see Section 6.1).

- `takefocus:B` : Determines whether the window accepts the focus during keyboard traversal (e.g., Tab and Shift-Tab). Before setting the focus to a window, the traversal mechanims consult the value of the takeFocus option. A value of `false` means that the window should be skipped entirely during keyboard traversal. `true` means that the window should receive the input focus as long as it is viewable (it and all of its ancestors are mapped). `B` must be a boolean.

- `show:VS` : If this option is specified, then the true contents of the entry are not displayed in the window. Instead, each character in the entry's value will be displayed as the first character in the value of this option, such as `*`. This is useful, for example, if the entry is to be used to enter a password. If characters in the entry are selected and copied elsewhere, the information copied will be what is displayed, not the true contents of the entry. `VS` must be a virtual string.

- `state:A` : Specifies one of two states for the button: `normal` or `disabled`. If the entry is disabled then the value may not be changed using widget commands and no insertion cursor will be displayed, even if the input focus is in the widget. `A` must be one of these two atoms : `normal` or `disabled`.

- `width:I` : Specifies an integer value indicating the desired width of the entry window, in average-size characters of the widget's font. If the value is less than or equal to zero, the widget picks a size just large enough to hold its current text. `I` must be a valid index.

- `action:C` : Specifies an action to execute juste after the user modified the entry. `C` can take several different forms (see Section 4.3.1).

- `min:I` : Specifies the lower bound of the range the user can select the value. `I` must be an integer that is at least zero. This option can be specified at creation time only.

- `max:I` : Specifies the upper bound of the range the user can select the value. `I` must be an integer. This option can be specified at creation time only.

- `glue:A` : Specifies how a widget must fit in its own available place. `A` must be an atom that is any combination of `n`, `s`, `w` and `e`. If a direction is specified, the corresponding border is glued to its neighboor or border of the frame if there is no neighboor. If a direction is not specified, the corresponding border if such that the widget takes just the width or height it needs to draw itself. If none of opposite directions is specified, the widget is centered. For more details, see Section 4.1.

- `padx:P` : Specifies how much horizontal external padding to leave on each side of the widget. This space is added outside the widget border. `P` must be a valid screen distance (see Section 6.6)

- `pady:P` : Specifies how much vertical external padding to leave on each side of the widget. This space is added outside the widget border. `P` must be a valid screen distance (see Section 6.6)

- `feature:A` : Specifies a feature name for the container object to reference the object controlling this widget. For more details, see Section 4.2. `A` must be an atom.

- `handle:V` : Specifies a variable to reference the object controlling this widget. This variable is binded when the window is built. For more details, see Section 4.2. `V` must be a free variable.

- `tooltips:VS` : Specifies a tooltip for the widget. A tooltip is a small message that appears when the mouse cursor if left still over the widget for a while. If `VS` is set to `nil`, no tooltip will appear at all. `VS` must be a virtual string.

- `look:L` : Specifies a look to use for the widget. A look specifies default values for the parameters of widgets. This parameter can be specified at creation time only. Moreover changing a look will not change the appearance of widgets that are already displayed with that look. See Section 6.2 for more details.

### 5.15.3 Interface

The object you get by an handle on the widget implements the following methods :

- `set(parameter1:value1 ... parameterX:valueX)` : Changes the value of one or more parameters. `parameterX` must be a valid parameter for the widget. `valueX` must be a valid value for the parameter.

- `get(parameter1:Variable1 ... parameterX:VariableX)` : Obtains the value of one or more parameters. `parameterX` must be a valid parameter for the widget. `VariableX` must be free variables which will receive the current value of the parameters.

- `bind(event:E
  args:LA
  action:A)` : Specifies an action `LA` to execute when the event `E` is triggered. The event can have parameters (like mouse coordinates for a mouse click). You must explicitly ask in the `LA` list the parameters you are interested for. For more details, see Section 4.3.3.

- `getFocus(force:B)` : if `B` is `false` (which is the default) : if the application currently has the input focus on window's display, this command resets the input focus for window's display to window. If the application doesn't currently have the input focus on window's display, window will be remembered as the focus for its top-level; the next time the focus arrives at the top-level, it will be redirected it to window. If `B` is `true` : sets the focus of window's display to window, even if the application doesn't currently have the input focus for the display. This command should be used sparingly, if at all. In normal usage, an application should not claim the focus for itself; instead, it should wait for the window manager to give it the focus. `B` must be a boolean.

- `setGrab(global:B)` : Sets a grab on the widget. If `B` is `true` then the grab is global, otherwise it is local (`B` false by default). If a grab was already in effect for this application then it is automatically released. If there is already a grab on the widget and it has the same global/local form as the requested grab, then the command does nothing. Local grab affects only the grabbing application: events will be reported to other applications as if the grab had never occurred. A global grab locks out all applications on the screen, so that only the given subtree of the grabbing application will be sensitive to pointer events (mouse button presses, mouse button releases, pointer motions, window entries, and window exits). During global grabs the window manager will not receive pointer events either. Warning : whe a grab is set, it is define for the whole Oz process so that it will prevent the user to do input to other windows as well. Moreover a grab is still effective even if the window that contains the grabbed widgets is hidden. `B` must be a boolean.

- `releaseGrab` : Releases the grab on the widget if there is one, otherwise does nothing.

- `getGrabStatus(1:V)` : Binds `V` to the atom `none` if there is no grab on the widget, to the atom `local` if there is a local grab and to `global` if there is a global grab. `V` must be a free variable.

- `'raise'(1:W)` : If the `W` argument is omitted then the command raises the widget so that it is above all of its siblings in the stacking order (it will not be obscured by any siblings and will obscure any siblings that overlap it). If `W` is specified then it must be an handle to another widget that is either a sibling of this widget or the descendant of a sibling of this widget. In this case the `'raise'` command will insert this widget into the stacking order just above `W`; this could end up either raising or lowering window.

- `lower(1:W)` : If the `W` argument is omitted then the command lowers the widget so that it is below all of its siblings in the stacking order (it will be obscured by any siblings and will not obscure any siblings that overlap it). If `W` is specified then it must be an handle to another widget that is either a sibling of this widget or the descendant of a sibling of this widget. In this case the `lower` command will insert this widget into the stacking order just below `W`; this could end up either raising or lowering window.

- `winfo(parameter1:value1 ... parameterX:valueX)` : This commands works like the `get` method, but for window-related information. For more details, see Section 6.9.

- `icursor(I)` : Arrange for the insertion cursor to be displayed just before the character given by `I`. `I` must be an integer.

- `scan(...)` : This command is used to implement scanning on entries. It has two forms, depending on option:

  - `scan(mark X Y)` : Records X and Y and the entry's current view; used in conjunction with later `scan(dragto ...)` commands. Typically this command is associated with a mouse button press in the widget and `X` and `Y` are the coordinates of the mouse. `X` and `Y` must be valid distances (see Section 6.6).

  - `scan(dragto X Y)` : This command computes the difference between its `X` and `Y` arguments (which are typically mouse coordinates) and the `X` and `Y` arguments to the last `scan(mark ...)` command for the widget. It then adjusts the view by 10 times the difference in coordinates. This command is typically associated with mouse motion events in the widget, to produce the effect of dragging the listbox at high speed through its window.

- `index(A I)` : Binds I to an integer giving index value that corresponds to `A`.