Text

A text widget displays one or more lines of text and allows that text to be edited. Text widgets support embedded widgets or embedded images.

Constructors

this
this(UiElement parent)

Construct the widget.

Members

Functions

appendText
auto appendText(string text)

Appends text to the widget.

clear
auto clear()

Delete all content from the widget.

copyText
auto copyText()

Copy the selected text to the clipboard.

cutText
auto cutText()

Cut the selected text to the clipboard.

deleteText
auto deleteText(int fromLine, int fromChar, int toLine, int toChar)

Delete text from the widget.

embedImage
auto embedImage(int line, int character, Image image, int padding)

Embed an image into the text.

embedWidget
auto embedWidget(int line, int character, Widget widget, int padding)

Embed a widget into the text.

getText
string getText()

Get the text from the widget.

insertText
auto insertText(int line, int character, string text)

Inserts text into the widget at a specified line and character index.

pasteText
auto pasteText()

Paste the selected text from the clipboard at the cursor position.

redo
auto redo()

Redo the last edit to the widget. This only applied to the widget if undo is enabled.

resetUndo
auto resetUndo()

Clear all undo's. This only applied to the widget if undo is enabled.

seeText
auto seeText(int line, int character)

See a particular text index. The text widget automatically scrolls to see the passed indexes.

setPadding
auto setPadding(int padding)

Set the amount of padding in the text widget.

setReadOnly
auto setReadOnly(bool readOnly)

Set if the widget is readonly or not.

setUndoLevels
auto setUndoLevels(int undoLevels)

Set the number of undo levels the widget will support.

setUndoSupport
auto setUndoSupport(bool enable)

Enable or disable undo support.

setWrapMode
auto setWrapMode(string mode)

Set the wrap mode of the text.

undo
auto undo()

Undo the last edit to the widget. This only applied to the widget if undo is enabled.

Mixins

__anonymous
mixin Border

Mixin common commands.

__anonymous
mixin Color
Undocumented in source.
__anonymous
mixin Font
Undocumented in source.
__anonymous
mixin Height
Undocumented in source.
__anonymous
mixin Relief
Undocumented in source.
__anonymous
mixin Width
Undocumented in source.
__anonymous
mixin XScrollCommand!(Text)
Undocumented in source.
__anonymous
mixin XView
Undocumented in source.
__anonymous
mixin YScrollCommand!(Text)
Undocumented in source.
__anonymous
mixin YView
Undocumented in source.

Mixed In Members

From mixin Border

setBorderWidth
auto setBorderWidth(int width)

Set the border width of the widget.

From mixin Color

setForegroundColor
auto setForegroundColor(string color)

Set the foreground color of the widget.

setBackgroundColor
auto setBackgroundColor(string color)

Set the background color of the widget.

setInsertColor
auto setInsertColor(string color)

Set the insert cursor color of the widget.

From mixin Font

setFont
auto setFont(string font, int size, FontStyle[] styles)

Set the font and style for the widget.

setFont
auto setFont(string fontInfo)

Set the font and style for the widget via a simple string. This method is exists to set the font using the output of the font dialog.

From mixin Height

setHeight
auto setHeight(int height)

Set the height of the widget if the geometry manager allows.

From mixin Relief

setRelief
auto setRelief(string relief)

Set the relief type of the widget.

From mixin Width

setWidth
auto setWidth(int width)

Set the width of the widget if the geometry manager allows.

From mixin XView

getXView
double[] getXView()

Get floating point values which represent the viewable portion of the text. Each element is a real fraction between 0 and 1; together they describe the horizontal span that is visible in the window. For example, if the first element is .2 and the second element is .6, 20% of the entry's text is off-screen to the left, the middle 40% is visible in the window, and 40% of the text is off-screen to the right.

setXView
auto setXView(double position)

Adjusts the view in the window so that the position appears at the left edge of the window. Position must be a fraction between 0.0 (start of the text) and 1.0 (end of the text).

scrollXToChar
auto scrollXToChar(int charIndex)

Adjusts the view in the window so that the character index passed is displayed at the left edge of the window.

scrollXChars
auto scrollXChars(int numberOfChars)

Scroll the text by a specified amount of characters. Positive values scroll text to the left, negative values scroll text to the right.

scrollXPages
auto scrollXPages(int numberOfPages)

Scroll the text by a specified amount of pages. Positive values scroll text to the left, negative values scroll text to the right.

From mixin YView

getYView
double[] getYView()

Get floating point values which represent the viewable portion of the text. Each element is a real fraction between 0 and 1; together they describe the vertical span that is visible in the window. For example, if the first element is .2 and the second element is .6, 20% of the entry's text is off-screen to the bottom, the middle 40% is visible in the window, and 40% of the text is off-screen to the bottom.

setYView
auto setYView(double position)

Adjusts the view in the window so that the position appears at the top edge of the window. Position must be a fraction between 0.0 (start of the text) and 1.0 (end of the text).

scrollYToChar
auto scrollYToChar(int charIndex)

Adjusts the view in the window so that the character index passed is displayed at the top edge of the window.

scrollYChars
auto scrollYChars(int numberOfChars)

Scroll the text by a specified amount of characters. Positive values scroll text to the down, negative values scroll text up.

scrollYPages
auto scrollYPages(int numberOfPages)

Scroll the text by a specified amount of pages. Positive values scroll text up, negative values scroll text down.

Inherited Members

From Widget

setState
auto setState(string[] state)

Set the widget's state.

getState
string[] getState()

Get the widget's state.

inState
bool inState(string[] state)

Test if a widget is in a particular state.

removeState
auto removeState(string[] state)

Remove the widget's state.

resetState
auto resetState()

Reset the widget's state to default.

setStyle
auto setStyle(string style)

Set the widget's style.

getStyle
string getStyle()

Get the widget's style.

setKeyboardFocus
auto setKeyboardFocus(string focus)

Set if the widget can recieve focus during keyboard traversal.

getKeyboardFocus
string getKeyboardFocus()

Get if the widget can recieve focus during keyboard traversal.

pack
auto pack(int outerPadding, int innerPadding, string side, string fill, string anchor, bool expand)

Geometry method for loosely placing this widget inside its parent using a web browser model. Widgets flow around each other in the available space.

grid
auto grid(int column, int row, int outerPadding, int innerPadding, int columnSpan, int rowSpan, string sticky)

Geometry method for placing this widget inside its parent using an imaginary grid. Somewhat more direct and intuitive than pack. Choose grid for tabular layouts, and when there's no good reason to choose something else.

place
auto place(int xPos, int yPos, int width, int height, string anchor, string borderMode)

Geometry method for placing this widget inside its parent using absolute positioning.

place
auto place(double relativeXPos, double relativeYPos, double relativeWidth, double relativeHeight, string anchor, string borderMode)

Geometry method for placing this widget inside its parent using relative positioning. In this case the position and size is specified as a floating-point number between 0.0 and 1.0 relative to the height of the parent. 0.5 means the widget will be half as high as the parent and 1.0 means the widget will have the same height as the parent, and so on.

Examples

auto text = new Text()
	.appendText("Text")
	.pack();

Common Commands

These are injected common commands that can also be used with this widget.

Border
Color
Font
Height
Relief
Width
XScrollCommand
XView
YScrollCommand
YView

Additional Events

Additional events that can also be bound to using the bind method.

<<Clear>>, <<Copy>>, <<Cut>>, <<Modified>>, <<Paste>>, <<PasteSelection>>, <<PrevWindow>>, <<Redo>>, <<Selection>>, <<Undo>>, <Alt-Key>, <B1-Enter>, <B1-Leave>, <B1-Motion>, <B2-Motion>, <Button-1>, <Button-2>, <Button-4>, <Button-5>, <ButtonRelease-1>, <Control-Button-1>, <Control-Key-Down>, <Control-Key-End>, <Control-Key-Home>, <Control-Key-Left>, <Control-Key-Next>, <Control-Key-Prior>, <Control-Key-Right>, <Control-Key-Tab>, <Control-Key-Up>, <Control-Key-a>, <Control-Key-b>, <Control-Key-backslash>, <Control-Key-d>, <Control-Key-e>, <Control-Key-f>, <Control-Key-h>, <Control-Key-i>, <Control-Key-k>, <Control-Key-n>, <Control-Key-o>, <Control-Key-p>, <Control-Key-slash>, <Control-Key-space>, <Control-Key-t>, <Control-Key>, <Control-Shift-Key-Down>, <Control-Shift-Key-End>, <Control-Shift-Key-Home>, <Control-Shift-Key-Left>, <Control-Shift-Key-Right>, <Control-Shift-Key-Tab>, <Control-Shift-Key-Up>, <Control-Shift-Key-space>, <Double-Button-1>, <Double-Shift-Button-1>, <Key-BackSpace>, <Key-Delete>, <Key-Down>, <Key-End>, <Key-Escape>, <Key-F10>, <Key-Home>, <Key-Insert>, <Key-KP_Enter>, <Key-Left>, <Key-Next>, <Key-Prior>, <Key-Return>, <Key-Right>, <Key-Select>, <Key-Tab>, <Key-Up>, <Key>, <Meta-Key-BackSpace>, <Meta-Key-Delete>, <Meta-Key-b>, <Meta-Key-d>, <Meta-Key-f>, <Meta-Key-greater>, <Meta-Key-less>, <Meta-Key>, <MouseWheel>, <Shift-Button-1>, <Shift-Key-Down>, <Shift-Key-End>, <Shift-Key-Home>, <Shift-Key-Left>, <Shift-Key-Next>, <Shift-Key-Prior>, <Shift-Key-Right>, <Shift-Key-Select>, <Shift-Key-Tab>, <Shift-Key-Up>, <Triple-Button-1>, <Triple-Shift-Button-1>,

See Also

Meta