Index

## Global Objects

- rap
- SWT

## Types

- $
- Button
- Canvas
- Client
- Combo
- Composite
- Control
- Event
- Label
- ProgressBar
- RemoteObject
- Scale
- ScrolledComposite
- Slider
- Spinner
- Text
- Widget

# Type Control

Extends Widget.
RWT Scripting analog to org.eclipse.swt.widgets.Control. All controls given by rap.getObject are instances of this type, even if their specific subtype is not documented.

Fields borrowed from class Widget:
  $el

Method Summary
Method Attributes | Method Name and Description
--- | ---
| addListener(type, listener) Register the function as a listener of the given type
| forceFocus() Forces the receiver to have the keyboard focus, causing all keyboard events to be delivered to it.
| getBackground() Returns the receiver's background color.
| getCursor() Returns the receiver's cursor, or null if it has not been set.
| getEnabled() Returns `true` if the receiver is enabled, and `false` otherwise.
| getForeground() Returns the receiver's foreground color.
| getToolTipText() Returns the receiver's tool tip text, or null if it has not been set.
| getVisible() Returns `true` if the receiver is visible, and `false` otherwise.
| removeListener(type, listener) De-register the function as a listener of the given type
| setBackground(color) Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.
| setEnabled(enabled) Enables the receiver if the argument is `true`, and disables it otherwise.
| setForeground(color) Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.
| setToolTipText(toolTipText) Sets the receiver's tool tip text to the argument, which may be null indicating that no tool tip text should be shown.
| setVisible(visible) Marks the receiver as visible if the argument is `true`, and marks it invisible otherwise.

Methods borrowed from class Widget:
  getData, setData

Event Summary
Event Attributes | Event Name and Description
--- | ---
| Dispose Sent when the widget is disposed.
| FocusIn Sent when the widget gains focus
| FocusOut Sent when the widget looses focus
| Hide Sent when the widget is hidden
| KeyDown Sent when a key is pressed
| KeyUp Sent when a key is released
| MouseDoubleClick Sent when a mouse button is clicked twice
| MouseDown Sent when a mouse button is pressed
| MouseEnter Sent when the mouse pointer enters the widget
| MouseExit Sent when the mouse pointer exits the widget
| MouseMove Sent when the mouse pointer is moved
| MouseUp Sent when a mouse button is released
| MouseWheel Sent when the mouse wheel is moved
| Paint Sent when the widget is painted
| Show Sent when the widget appears

Type Detail
<private> Control()
The constructor is not public.

Since:
  2.2

Method Detail
addListener(type, listener)
Register the function as a listener of the given type

Parameters:
{string} type
  The type of the event (e.g. SWT.Resize).
{Function} listener
  The callback function. It is executed in global context.

{boolean} forceFocus()
Forces the receiver to have the keyboard focus, causing all keyboard events to be delivered to it.

Returns:
  {boolean} `true` if the control got focus, and `false` if it was unable to.

{int[]} getBackground()
Returns the receiver's background color.

Returns:
  {int[]} the background color as array [ red, green, blue ]

{string|null} getCursor()
Returns the receiver's cursor, or null if it has not been set.

When the mouse pointer passes over a control its appearance is changed to match the control's cursor.

All possible values are available as constants on the SWT object.

Returns:
  {string|null} the receiver's cursor or `null`

{boolean} getEnabled()
Returns `true` if the receiver is enabled, and `false` otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.

Returns:
  {boolean} the receiver's enabled state

{int[]} getForeground()
Returns the receiver's foreground color.

Returns:
  {int[]} the foreground color as array [ red, green, blue ]

{string|null} getToolTipText()
Returns the receiver's tool tip text, or null if it has not been set.

Returns:
  {string|null} the receiver's tool tip text

{boolean} getVisible()
Returns `true` if the receiver is visible, and `false` otherwise.

If one of the receiver's ancestors is not visible or some other condition makes the receiver not visible, this method may still indicate that it is considered visible even though it may not actually be showing.

Returns:
  {boolean} the receiver's visibility state

removeListener(type, listener)
De-register the function as a listener of the given type

Parameters:
{string} type
  The type of the event (e.g. SWT.Resize).
{Function} listener
  The callback function

setBackground(color)
Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.

Parameters:
{int[]|null} color
  the new color as array [ red, green, blue ] or null

setEnabled(enabled)
Enables the receiver if the argument is `true`, and disables it otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.

Parameters:
{boolean} enabled
  the new enabled state

setForeground(color)
Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.

Parameters:
{int[]|null} color
  the new color as array [ red, green, blue ] or null

setToolTipText(toolTipText)
Sets the receiver's tool tip text to the argument, which may be null indicating that no tool tip text should be shown.

Parameters:
{string|null} toolTipText
  the new tool tip text (or null)

setVisible(visible)
Marks the receiver as visible if the argument is `true`, and marks it invisible otherwise.

If one of the receiver's ancestors is not visible or some other condition makes the receiver not visible, marking it visible may not actually cause it to be displayed.

NOTE: If there is a `Show` or `Hide` Java listener attached to this widget, it may be notified at a later point in time. `ClientListener` are notified right away.

Parameters:
{boolean} visible
  the new visibility state

Event Detail
Dispose
Sent when the widget is disposed. The event is fired before widget is detached from the widget hierarchy and removed from DOM

Parameters:
{Event} event

See:
  SWT.Dispose

FocusIn
Sent when the widget gains focus

Parameters:
{Event} event

See:
  SWT.FocusIn

FocusOut
Sent when the widget looses focus

Parameters:
{Event} event

See:
  SWT.FocusOut

Hide
Sent when the widget is hidden

Parameters:
{Event} event

See:
  SWT.Hide

KeyDown
Sent when a key is pressed

Parameters:
{Event} event

See:
  SWT.KeyDown

KeyUp
Sent when a key is released

Parameters:
{Event} event

See:
  SWT.KeyUp

MouseDoubleClick
Sent when a mouse button is clicked twice

Parameters:
{Event} event

See:
  SWT.MouseDoubleClick

MouseDown
Sent when a mouse button is pressed

Parameters:
{Event} event

See:
  SWT.MouseDown

MouseEnter
Sent when the mouse pointer enters the widget

Parameters:
{Event} event

See:
  SWT.MouseEnter

MouseExit
Sent when the mouse pointer exits the widget

Parameters:
{Event} event

See:
  SWT.MouseExit

MouseMove
Sent when the mouse pointer is moved

Parameters:
{Event} event

See:
  SWT.MouseMove

MouseUp
Sent when a mouse button is released

Parameters:
{Event} event

See:
  SWT.MouseUp

MouseWheel
Sent when the mouse wheel is moved

Parameters:
{Event} event

See:
  SWT.MouseWheel

Paint
Sent when the widget is painted

Parameters:
{Event} event

See:
  SWT.Paint

Show
Sent when the widget appears

Parameters:
{Event} event

See:
  SWT.Show

Copyright (c) EclipseSource and others 2013, 2022. All rights reserved.