Spinner

Instances of this class are selectable user interface objects that allow the user to enter and modify numeric values. <p> Note that although this class is a subclass of <code>Composite</code>, it does not make sense to add children to it, or set a layout on it. </p><p> <dl> <dt><b>Styles:</b></dt> <dd>READ_ONLY, WRAP</dd> <dt><b>Events:</b></dt> <dd>Selection, Modify, Verify</dd> </dl> </p><p> IMPORTANT: This class is <em>not</em> intended to be subclassed. </p>

@see <a href="http://www.eclipse.org/swt/snippets/#spinner">Spinner snippets</a> @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a> @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>

@since 3.1

Constructors

this
this(Composite parent, int style)

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance. <p> The style value is either one of the style constants defined in class <code>SWT</code> which is applicable to instances of this class, or must be built by <em>bitwise OR</em>'ing together (that is, using the <code>int</code> "|" operator) two or more of those <code>SWT</code> style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses. </p>

Members

Functions

addModifyListener
void addModifyListener(ModifyListener listener)

Adds the listener to the collection of listeners who will be notified when the receiver's text is modified, by sending it one of the messages defined in the <code>ModifyListener</code> interface.

addSelectionListener
void addSelectionListener(SelectionListener listener)

Adds the listener to the collection of listeners who will be notified when the control is selected by the user, by sending it one of the messages defined in the <code>SelectionListener</code> interface. <p> <code>widgetSelected</code> is not called for texts. <code>widgetDefaultSelected</code> is typically called when ENTER is pressed in a single-line text. </p>

addVerifyListener
void addVerifyListener(VerifyListener listener)

Adds the listener to the collection of listeners who will be notified when the receiver's text is verified, by sending it one of the messages defined in the <code>VerifyListener</code> interface.

copy
void copy()

Copies the selected text. <p> The current selection is copied to the clipboard. </p>

cut
void cut()

Cuts the selected text. <p> The current selection is first copied to the clipboard and then deleted from the widget. </p>

getDigits
int getDigits()

Returns the number of decimal places used by the receiver.

getIncrement
int getIncrement()

Returns the amount that the receiver's value will be modified by when the up/down arrows are pressed.

getMaximum
int getMaximum()

Returns the maximum value which the receiver will allow.

getMinimum
int getMinimum()

Returns the minimum value which the receiver will allow.

getPageIncrement
int getPageIncrement()

Returns the amount that the receiver's position will be modified by when the page up/down keys are pressed.

getSelection
int getSelection()

Returns the <em>selection</em>, which is the receiver's position.

getText
String getText()

Returns a string containing a copy of the contents of the receiver's text field, or an empty string if there are no contents.

getTextLimit
int getTextLimit()

Returns the maximum number of characters that the receiver's text field is capable of holding. If this has not been changed by <code>setTextLimit()</code>, it will be the constant <code>Spinner.LIMIT</code>.

paste
void paste()

Pastes text from clipboard. <p> The selected text is deleted from the widget and new text inserted from the clipboard. </p>

removeModifyListener
void removeModifyListener(ModifyListener listener)

Removes the listener from the collection of listeners who will be notified when the receiver's text is modified.

removeSelectionListener
void removeSelectionListener(SelectionListener listener)

Removes the listener from the collection of listeners who will be notified when the control is selected by the user.

removeVerifyListener
void removeVerifyListener(VerifyListener listener)

Removes the listener from the collection of listeners who will be notified when the control is verified.

setDigits
void setDigits(int value)

Sets the number of decimal places used by the receiver. <p> The digit setting is used to allow for floating point values in the receiver. For example, to set the selection to a floating point value of 1.37 call setDigits() with a value of 2 and setSelection() with a value of 137. Similarly, if getDigits() has a value of 2 and getSelection() returns 137 this should be interpreted as 1.37. This applies to all numeric APIs. </p>

setIncrement
void setIncrement(int value)

Sets the amount that the receiver's value will be modified by when the up/down arrows are pressed to the argument, which must be at least one.

setMaximum
void setMaximum(int value)

Sets the maximum value that the receiver will allow. This new value will be ignored if it is not greater than the receiver's current minimum value. If the new maximum is applied then the receiver's selection value will be adjusted if necessary to fall within its new range.

setMinimum
void setMinimum(int value)

Sets the minimum value that the receiver will allow. This new value will be ignored if it is not less than the receiver's current maximum value. If the new minimum is applied then the receiver's selection value will be adjusted if necessary to fall within its new range.

setPageIncrement
void setPageIncrement(int value)

Sets the amount that the receiver's position will be modified by when the page up/down keys are pressed to the argument, which must be at least one.

setSelection
void setSelection(int value)

Sets the <em>selection</em>, which is the receiver's position, to the argument. If the argument is not within the range specified by minimum and maximum, it will be adjusted to fall within this range.

setTextLimit
void setTextLimit(int limit)

Sets the maximum number of characters that the receiver's text field is capable of holding to be the argument. <p> To reset this value to the default, use <code>setTextLimit(Spinner.LIMIT)</code>. Specifying a limit value larger than <code>Spinner.LIMIT</code> sets the receiver's limit to <code>Spinner.LIMIT</code>. </p> @param limit new text limit

setValues
void setValues(int selection, int minimum, int maximum, int digits, int increment, int pageIncrement)

Sets the receiver's selection, minimum value, maximum value, digits, increment and page increment all at once. <p> Note: This is similar to setting the values individually using the appropriate methods, but may be implemented in a more efficient fashion on some platforms. </p>

Static variables

LIMIT
int LIMIT;

the operating system limit for the number of characters that the text field in an instance of this class can hold

Inherited Members

From Composite

changed
void changed(Control[] changed)

Clears any data that has been cached by a Layout for all widgets that are in the parent hierarchy of the changed control up to and including the receiver. If an ancestor does not have a layout, it is skipped.

getBackgroundMode
int getBackgroundMode()

Returns the receiver's background drawing mode. This will be one of the following constants defined in class <code>SWT</code>: <code>INHERIT_NONE</code>, <code>INHERIT_DEFAULT</code>, <code>INHERTIT_FORCE</code>.

getChildren
Control[] getChildren()

Returns a (possibly empty) array containing the receiver's children. Children are returned in the order that they are drawn. The topmost control appears at the beginning of the array. Subsequent controls draw beneath this control and appear later in the array. <p> Note: This is not the actual structure used by the receiver to maintain its list of children, so modifying the array will not affect the receiver. </p>

getLayout
Layout getLayout()

Returns layout which is associated with the receiver, or null if one has not been set.

getLayoutDeferred
bool getLayoutDeferred()

Returns <code>true</code> if the receiver has deferred the performing of layout, and <code>false</code> otherwise.

getTabList
Control[] getTabList()

Gets the (possibly empty) tabbing order for the control.

isLayoutDeferred
bool isLayoutDeferred()

Returns <code>true</code> if the receiver or any ancestor up to and including the receiver's nearest ancestor shell has deferred the performing of layouts. Otherwise, <code>false</code> is returned.

layout
void layout()

If the receiver has a layout, asks the layout to <em>lay out</em> (that is, set the size and location of) the receiver's children. If the receiver does not have a layout, do nothing. <p> This is equivalent to calling <code>layout(true)</code>. </p> <p> Note: Layout is different from painting. If a child is moved or resized such that an area in the parent is exposed, then the parent will paint. If no child is affected, the parent will not paint. </p>

layout
void layout(bool changed)

If the receiver has a layout, asks the layout to <em>lay out</em> (that is, set the size and location of) the receiver's children. If the argument is <code>true</code> the layout must not rely on any information it has cached about the immediate children. If it is <code>false</code> the layout may (potentially) optimize the work it is doing by assuming that none of the receiver's children has changed state since the last layout. If the receiver does not have a layout, do nothing. <p> If a child is resized as a result of a call to layout, the resize event will invoke the layout of the child. The layout will cascade down through all child widgets in the receiver's widget tree until a child is encountered that does not resize. Note that a layout due to a resize will not flush any cached information (same as <code>layout(false)</code>). </p> <p> Note: Layout is different from painting. If a child is moved or resized such that an area in the parent is exposed, then the parent will paint. If no child is affected, the parent will not paint. </p>

layout
void layout(bool changed, bool all)

If the receiver has a layout, asks the layout to <em>lay out</em> (that is, set the size and location of) the receiver's children. If the changed argument is <code>true</code> the layout must not rely on any information it has cached about its children. If it is <code>false</code> the layout may (potentially) optimize the work it is doing by assuming that none of the receiver's children has changed state since the last layout. If the all argument is <code>true</code> the layout will cascade down through all child widgets in the receiver's widget tree, regardless of whether the child has changed size. The changed argument is applied to all layouts. If the all argument is <code>false</code>, the layout will <em>not</em> cascade down through all child widgets in the receiver's widget tree. However, if a child is resized as a result of a call to layout, the resize event will invoke the layout of the child. Note that a layout due to a resize will not flush any cached information (same as <code>layout(false)</code>). </p> <p> Note: Layout is different from painting. If a child is moved or resized such that an area in the parent is exposed, then the parent will paint. If no child is affected, the parent will not paint. </p>

layout
void layout(Control[] changed)

Forces a lay out (that is, sets the size and location) of all widgets that are in the parent hierarchy of the changed control up to and including the receiver. The layouts in the hierarchy must not rely on any information cached about the changed control or any of its ancestors. The layout may (potentially) optimize the work it is doing by assuming that none of the peers of the changed control have changed state since the last layout. If an ancestor does not have a layout, skip it. <p> Note: Layout is different from painting. If a child is moved or resized such that an area in the parent is exposed, then the parent will paint. If no child is affected, the parent will not paint. </p>

setBackgroundMode
void setBackgroundMode(int mode)

Sets the background drawing mode to the argument which should be one of the following constants defined in class <code>SWT</code>: <code>INHERIT_NONE</code>, <code>INHERIT_DEFAULT</code>, <code>INHERIT_FORCE</code>.

setLayout
void setLayout(Layout layout)

Sets the layout which is associated with the receiver to be the argument which may be null.

setLayoutDeferred
void setLayoutDeferred(bool defer)

If the argument is <code>true</code>, causes subsequent layout operations in the receiver or any of its children to be ignored. No layout of any kind can occur in the receiver or any of its children until the flag is set to false. Layout operations that occurred while the flag was <code>true</code> are remembered and when the flag is set to <code>false</code>, the layout operations are performed in an optimized manner. Nested calls to this method are stacked.

setTabList
void setTabList(Control[] tabList)

Sets the tabbing order for the specified controls to match the order that they occur in the argument list.

Meta