TextEdit
Plain text input view.
Module | require("yue.gui") |
Type | Class |
Inherits | View |
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
string
text
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
integer
startinteger
end
gettextinrange(start, end)
Return the text between start
and end
positions.
Parameters
integer
startinteger
end
Return
string
inserttext(text)
Insert text
at current caret position.
Parameters
string
text
inserttextat(text, position)
Insert text
at the position
.
Parameters
string
textinteger
position
delete()
Delete text of current selection.
deleterange(start, end)
Delete text between start
and end
positions.
Parameters
integer
startinteger
end
macOS linux
setoverlayscrollbar(overlay)Set whether to use overlay scrolling.
Parameters
boolean
overlay
setscrollbarpolicy(hpolicy, vpolicy)
Set the policy for displaying horizontal and vertical scrollbars.
Parameters
Scroll::Policy
hpolicy - Policy for horizontal scrollbar.Scroll::Policy
vpolicy - Policy for vertical scrollbar.
macOS
setscrollelasticity(helasticity, velasticity)Set horizontal and vertical scroll elasticity (bounce).
Parameters
Scroll::Elasticity
helasticity - Horizontal scroll elasticity.Scroll::Elasticity
velasticity - Vertical scroll elasticity.
macOS
getscrollelasticity()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
TextEdit
self
Preventable
No.Delegates
shouldinsertnewline(self)
Called when user presses Return
to insert new line, should return
whether it is allowed.
Parameters
TextEdit
self
Return
boolean