TextEdit

Plain text input view.

Modulerequire("yue.gui")
TypeClass
InheritsView

The selection range in TextEdit use 0-based index, the start and end both start from 0, and end is the index of the character after the range.

Using -1 as end means the end of the text.

The range uses character index instead of byte index, be careful when using programming languages without Unicode support.

Class methods

create()

Create a new TextEdit.

Return

TextEdit

Methods

settext(text)

Change the text in the view.

Parameters

gettext()

Return currently displayed text.

Return

string

undo()

Undo the last edit operation in the undo queue.

canundo()

Return whether there are any actions in undo queue.

redo()

Redo the next action in the redo queue

canredo()

Return whether there are any actions in redo queue.

cut()

Delete (cut) the current selection, if any, copy the deleted text to the clipboard.

copy()

Copy current selection to clipboard.

paste()

Copy the current content of the clipboard to current caret position.

selectall()

Select all text.

getselectionrange()

Return the start position and end position of current selection.

If nothing is selected, the cursor position will be returned as both values, ie. (0, 0).

Return

integer, integer

selectrange(start, end)

Select text between start and end positions.

Parameters

gettextinrange(start, end)

Return the text between start and end positions.

Parameters

Return

string

inserttext(text)

Insert text at current caret position.

Parameters

inserttextat(text, position)

Insert text at the position.

Parameters

delete()

Delete text of current selection.

deleterange(start, end)

Delete text between start and end positions.

Parameters

setoverlayscrollbar(overlay) macOS linux

Set whether to use overlay scrolling.

Parameters

setscrollbarpolicy(hpolicy, vpolicy)

Set the policy for displaying horizontal and vertical scrollbars.

Parameters

setscrollelasticity(helasticity, velasticity) macOS

Set horizontal and vertical scroll elasticity (bounce).

Parameters

getscrollelasticity() macOS

Return the horizontal and vertical scroll elasticity.

Return

Scroll::Elasticity, Scroll::Elasticity

gettextbounds()

Return the text extend.

Return

RectF

Events

ontextchange(self)

Emitted when user has changed text.

Parameters

Preventable

No.

Delegates

shouldinsertnewline(self)

Called when user presses Return to insert new line, should return whether it is allowed.

Parameters

Return

boolean