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
TextEditMethods
settext(text)
Change the text in the view.
Parameters
stringtext
gettext()
Return currently displayed text.
Return
stringundo()
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, integerselectrange(start, end)
Select text between start and end positions.
Parameters
integerstartintegerend
gettextinrange(start, end)
Return the text between start and end positions.
Parameters
integerstartintegerend
Return
stringinserttext(text)
Insert text at current caret position.
Parameters
stringtext
inserttextat(text, position)
Insert text at the position.
Parameters
stringtextintegerposition
delete()
Delete text of current selection.
deleterange(start, end)
Delete text between start and end positions.
Parameters
integerstartintegerend
setoverlayscrollbar(overlay) macOS linux
Set whether to use overlay scrolling.
Parameters
booleanoverlay
setscrollbarpolicy(hpolicy, vpolicy)
Set the policy for displaying horizontal and vertical scrollbars.
Parameters
Scroll::Policyhpolicy - Policy for horizontal scrollbar.Scroll::Policyvpolicy - Policy for vertical scrollbar.
setscrollelasticity(helasticity, velasticity) macOS
Set horizontal and vertical scroll elasticity (bounce).
Parameters
Scroll::Elasticityhelasticity - Horizontal scroll elasticity.Scroll::Elasticityvelasticity - Vertical scroll elasticity.
getscrollelasticity() macOS
Return the horizontal and vertical scroll elasticity.
Return
Scroll::Elasticity, Scroll::Elasticitygettextbounds()
Return the text extend.
Return
RectFEvents
ontextchange(self)
Emitted when user has changed text.
Parameters
TextEditself
Preventable
No.Delegates
shouldinsertnewline(self)
Called when user presses Return to insert new line, should return
whether it is allowed.
Parameters
TextEditself
Return
boolean