TextEdit

Plain text input view.

Header#include "nativeui/text_edit.h"
Namespacenamespace nu
Typeclass (RefCounted)
InheritsView

Constructors

TextEdit()

Create a new TextEdit.

Class properties

const char* kClassName

The class name of this view.

Methods

void SetText(const std::string& text)

Change the text in the view.

Parameters

std::string GetText() const

Return currently displayed text.

Return

std::string

void Undo()

Undo the last edit operation in the undo queue.

void CanUndo() const

Return whether there are any actions in undo queue.

void Redo()

Redo the next action in the redo queue

void CanRedo() const

Return whether there are any actions in redo queue.

void Cut()

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

void Copy()

Copy current selection to clipboard.

void Paste()

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

void SelectAll()

Select all text.

std::tuple<int, int> GetSelectionRange() const

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

std::tuple

void SelectRange(int start, int end)

Select text between start and end positions.

Parameters

std::string GetTextInRange(int start, int end) const

Return the text between start and end positions.

Parameters

Return

std::string

void InsertText(const std::string& text)

Insert text at current caret position.

Parameters

void InsertTextAt(const std::string& text, int position)

Insert text at the position.

Parameters

void Delete()

Delete text of current selection.

void DeleteRange(int start, int end)

Delete text between start and end positions.

Parameters

void SetOverlayScrollbar(bool overlay) macOS linux

Set whether to use overlay scrolling.

Parameters

void SetScrollbarPolicy(Scroll::Policy hpolicy, Scroll::Policy vpolicy)

Set the policy for displaying horizontal and vertical scrollbars.

Parameters

RectF GetTextBounds() const

Return the text extend.

Return

RectF

Events

void on_text_change(TextEdit* self)

Emitted when user has changed text.

Parameters

Preventable

No.

Delegates

bool should_insert_new_line(TextEdit* self)

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

Parameters

Return

bool