View

Base class for GUI components.

Modulerequire("gui")
TypeClass

View provides methods to receive and change various style properties.

Methods

offsetFromView(view)

Return offset from view.

Parameters

Return

Vector2dF

offsetFromWindow()

Return offset from the window that owns the view.

Return

Vector2dF

getBounds()

Return the position and size of the view, relative to its parent.

Return

RectF

layout()

Make the view re-recalculate its layout.

schedulePaint()

Schedule to repaint the whole view.

setVisible(visible)

Show/Hide the view.

Parameters

isVisible()

Return whether the view is visible.

Return

Boolean

focus()

Move the keyboard focus to the view.

hasFocus()

Return whether the view has keyboard focus.

Return

Boolean

setFocusable(focusable)

Set whether the view can be focused on.

Parameters

isFocusable()

Return whether the view can be focused on.

Return

Boolean

setCapture()

Set mouse capture to the view.

releaseCapture()

Release mouse capture if the view has mouse capture.

hasCapture()

Return whether the view has mouse capture.

Return

Boolean

setMouseDownCanMoveWindow(can)

Set whether dragging mouse would move the window.

For most platforms this method only works for frameless windows, having this feature may also prevent mouse events to happen.

On macOS the Container view has this feature turned on by default. To turn this feature on for the view, the view's parent view must also has this feature turned on.

On Windows the view with this feature will be treated as titlebar, e.g. double-clicking would maximize the window, right-clicking may show the system menu.

Parameters

isMouseDownCanMoveWindow()

Return whether dragging the view would move the window.

Return

Boolean

setFont(font)

Change the font used for drawing text in the view.

This methods only works for Views that display text, like Label or Entry.

Parameters

setColor(color)

Change the color used for drawing text in the view.

This methods only works for Views that display text, like Label or Entry.

Parameters

setBackgroundColor(color)

Change the background color of the view.

Parameters

setStyle(styles)

Change the styles of the view.

Available style properties can be found at Layout System.

Parameters

getParent()

Return parent view.

Return

View

getWindow()

Return the window that the view belongs to.

Return

Window

Events

onMouseDown(self, event)

Emitted when pressing mouse buttons.

Parameters

Preventable

Yes.

onMouseUp(self, event)

Emitted when releasing mouse buttons.

Parameters

Preventable

Yes.

onMouseMove(self, event)

Emitted when user moves mouse in the view.

Parameters

Preventable

No.

onMouseEnter(self, event)

Emitted when mouse enters the view.

Parameters

Preventable

No.

onMouseLeave(self, event)

Emitted when mouse leaves the view.

Parameters

Preventable

No.

onKeyDown(self, event)

Emitted when pressing keyboard.

Parameters

Preventable

Yes.

onKeyUp(self, event)

Emitted when releasing keyboard.

Parameters

Preventable

Yes.

onSizeChanged(self)

Emitted when the view's size has been changed.

Parameters

Preventable

No.

onCaptureLost(self)

Emitted when the mouse capture on view has been released.

Parameters

Preventable

No.