# WRTKit Control Class

## Description

The Control class is an abstract base class for user interface controls. Don't instantiate Control directly but rather one of its subclasses.

## Inherits from

UIElement

## Events

- FocusStateChanged

  This event is fired when focus state of the control has changed.

- HoverStateChanged

  This event is fired when hover state of the control has changed.

Parent topic: WRTKit API Reference

## getCaption()

### Syntax

    [String] Control.getCaption(void)

### Description

Retrieves the current caption of the control. The value is an XHTML string.

### Arguments

This method does not take any arguments.

### Return value

The current caption of the control or null if the control doesn't have a caption.

## setCaption()

### Syntax

    [void] Control.setCaption(String caption)

### Description

Sets the caption for the control. If null is specified as the caption then the caption is removed (entirely hidden) for the control. The value is an XHTML string.

### Arguments

- caption

  The new caption for the control or null for no caption.

### Return value

This method does not return a value.

## isEnabled()

### Syntax

    [Boolean] Control.isEnabled(void)

### Description

Retrieves the enabled state of the control.

### Arguments

This method does not take any arguments.

### Return value

The current enabled state of the control.

## setEnabled()

### Syntax

    [void] Control.setEnabled(Boolean state)

### Description

Sets the enabled state for the control.

### Arguments

- state

  The new enabled state for the control; true to enable, false to disable.

### Return value

This method does not return a value.

## isFocusable()

### Syntax

    [Boolean] Control.isFocusable(void)

### Description

Retrieves the focusable state of a control. The focusable state tells whether the control can be focused or not. E.g. a label control cannot be focused because it does not have any interactive action to perform.

### Arguments

This method does not take any arguments.

### Return value

The focusable state of the control.

## isFocused()

### Syntax

    [Boolean] Control.isFocused(void)

### Description

Retrieves the focused state of the control.

### Arguments

This method does not take any arguments.

### Return value

The current focused state of the control.

## setFocused()

### Syntax

    [void] Control.setFocused(Boolean state)

### Description

Sets the focused state for the control. Note that it's not always possible to carry out the request to focus a control. E.g. a control might not be visible or the focus might be locked to another control.

### Arguments

- state

  The new focused state for the control; true to focus, false to blur.

### Return value

This method does not return a value.

## updateStyleFromState()

### Syntax

    [void] Control.updateStyleFromState()

### Description

Called to let the control update its style to match its internal state. The method doesn't need to be called manually as the toolkit takes care of calling it whenever the state of a control changes. Override this method if you wish to implement custom styling for a control. Typically using CSS rules will be sufficient for customizing looks so only use this method when CSS is insufficient.

### Arguments

This method does not take any arguments.

### Return value

This method does not return a value.

## view

### Syntax

    [View] Control.view

### Description

The view property references the view that the control is attached to. If the control has not been attached to any view then the property is null.