Skip to content

XUIInspectorTextFieldRenderer

Description

Handles rendering a text field to a graphics context.

Properties

Name Type Read-Only
Caption String
CaretPosition Integer
Contents String
Height Double
mBuffer Picture
mCachedVisibleWidth Double
mCaretPosition Integer
mCaretVisible Boolean
mCharacters() String
mCurrentSelection XUITextSelection
mHasFocus Boolean
mOwner WeakRef
mScrollOffset Integer
mStyle XUIInspectorStyle
Owner XUIInspector
Placeholder String
TextSelected Boolean
Width Double

Methods

Name Parameters Returns
CaretAtEnd Boolean
CaretXCoordinate Integer
CharacterAtCaret String
CharsToCaret String
ClearSelection
Constructor owner As XUIInspector, placeholder As String, caption As String
DeleteBackward
DeleteForward
DeleteSelection
DoubleClick x As Integer, y As Integer
InsertCharacter char As String, range As TextRange
MoveCaretLeft
MoveCaretRight
MoveCaretToNextWordEnd
MoveCaretToPreviousWordStart
MoveDownAndModifySelection
MoveLeftAndModifySelection
MoveRightAndModifySelection
MoveToBeginningOfLine
MoveToEndOfLine
MoveToLeftEndOfLineAndModifySelection
MoveToRightEndOfLineAndModifySelection
MoveUpAndModifySelection
MoveWordLeftAndModifySelection
NextWordEnd caretPos As Integer Integer
Owner XUIInspector
PaintCaret style As XUIInspectorStyle
PaintSelection selectionColor As ColorGroup
PreviousWordStart caretPos As Integer Integer
Render g As Graphics, x As Double, y As Double, width As Double, height As Double, style As XUIInspectorStyle, hasFocus As Boolean
ReplaceSelection s As String
ScrollToCaret visibleWidth As Double
SelectAll
SelectedText String
SelectWhitespaceAroundCaret
SelectWordAtCaret
TripleClick x As Integer, y As Integer
UpdateCaretPosition x As Double, y As Double
WidthToColumn column As Integer, g As Graphics Double

Constants

Name Type
HPADDING Double
LEFT_SCROLL_PADDING Double
RIGHT_SCROLL_PADDING Double
VPADDING Double

HPADDING As Double The number of pixels to pad the contents left and right.


LEFT_SCROLL_PADDING As Double The number of pixels to pad left when scrolling leftwards.


RIGHT_SCROLL_PADDING As Double Fudge factor for padding the right of the line when horizontal scrolling.


VPADDING As Double The number of pixels to pad the contents top and bottom.


Property Descriptions

Caption As String

Optional caption to display within the text field at the inner left edge.


CaretPosition As Integer

The current caret position. 0 is before the first character.


Contents As String

The contents of this text field.


Height As Double

The height of the text field.


mBuffer As Picture

The buffer picture representing this text field in its entirety (excluding borders and focus ring).


mCachedVisibleWidth As Double

Cached reference to the width parameter passed tot he Render method.


mCaretPosition As Integer

The current caret position. 0 is before the first character.


mCaretVisible As Boolean

If True then the caret will be drawn.


mCharacters() As String

The raw characters of this text field.


mCurrentSelection As XUITextSelection

Backing field for the CurrentSelection computed property.


mHasFocus As Boolean

If True then this text field has the focus.


mOwner As WeakRef

A weak reference to the XUIInspector which owns this text field. May be Nil.


mScrollOffset As Integer

The X scroll offset. 0 is baseline. Positive values indicate scrolling to the right.


mStyle As XUIInspectorStyle

Cached reference to the last style used in the Render method.


Owner As XUIInspector

A weak reference to the owning inspector. May be Nil if not yet added to an inspector.


Placeholder As String

Optional placeholder text.


TextSelected As Boolean

True if there is any text currently selected.


Width As Double

The width of the text field.


Method Descriptions

CaretAtEnd() As Boolean

True if the caret is at the end of the text.


CaretXCoordinate() As Integer

Returns the number of pixels from the left edge of the textfield the caret currently is.


CharacterAtCaret() As String

Returns the caret immediately in front of the caret. May return "".


CharsToCaret() As String

Returns the characters up to the caret.


ClearSelection()

Clears the selection (if there is one).


Constructor(owner As XUIInspector, placeholder As String, caption As String)

Constructs a new inspector text field renderer.


DeleteBackward()

Deletes the character before the caret.


DeleteForward()

Deletes the character immediately in front of the caret.


DeleteSelection()

Deletes the text in the current selection.


DoubleClick(x As Integer, y As Integer)

Handle a double click at x, y.


InsertCharacter(char As String, range As TextRange)

Inserts a single character at the current caret position.


MoveCaretLeft()

Moves the caret to the left one position.


MoveCaretRight()

Moves the caret one position to the right.


MoveCaretToNextWordEnd()

Moves the caret to the end of the next word.


MoveCaretToPreviousWordStart()

Moves the caret to the start of the previous word.


MoveDownAndModifySelection()

Moves down and modifies the selection.


MoveLeftAndModifySelection()

Moves the caret one position to the left and modifies the current selection.

The user has pressed Shift+Left arrow.


MoveRightAndModifySelection()

Moves the caret one position to the right and modifies the current selection.

The user has pressed Shift+Right arrow.


MoveToBeginningOfLine()

Moves the caret to the beginning of the line.


MoveToEndOfLine()

Moves the caret to the end of the line.


MoveToLeftEndOfLineAndModifySelection()

Moves the selection to the left end of the line.


MoveToRightEndOfLineAndModifySelection()

Moves the selection to the right end of the line.


MoveUpAndModifySelection()

Moves up and modifies the selection.


MoveWordLeftAndModifySelection()

Selects the text from the beginning of the word to the left of the caret to the current caret position.


NextWordEnd(caretPos As Integer) As Integer

Returns the caret position of the end of the word after the caretPos.

Raises an InvalidArgumentException if caretPos is out of range for this line.


Owner() As XUIInspector

A weak reference to the inspector this item belongs to.


PaintCaret(style As XUIInspectorStyle)

Paints the caret (if visible) at the current caret position.

Assumes mBuffer is not Nil.


PaintSelection(selectionColor As ColorGroup)

Paints the selection background to mBuffer if there is a selection.

Assumes mBuffer is not Nil.


PreviousWordStart(caretPos As Integer) As Integer

Returns the caret pos of the start of the word before the caretPos.

Raises an InvalidArgumentException if caretPos is out of range.


Render(g As Graphics, x As Double, y As Double, width As Double, height As Double, style As XUIInspectorStyle, hasFocus As Boolean)

Render this text field to g at x, y with the specified width and height.


ReplaceSelection(s As String)

Replaces the current selection with s.


ScrollToCaret(visibleWidth As Double)

Computes the required scroll offset to ensure that the caret is visible within visibleWidth.

Assumes mBuffer is not Nil.


SelectAll()

Select the entire contents of the text field.


SelectedText() As String

Returns the currently selected text or "" if there is no selection.


SelectWhitespaceAroundCaret()

Selects all whitespace around the current caret position on the caret's current line.


SelectWordAtCaret()

Selects the word the caret is within.


TripleClick(x As Integer, y As Integer)

Handles a triple click at x, y.


UpdateCaretPosition(x As Double, y As Double)

Updates the current caret position based on a click at x, y.

x, y does not factor in scrolling. Assumes mBuffer is not Nil. Assumes Render has been called at least once prior to this as we rely on it caching the style.


WidthToColumn(column As Integer, g As Graphics) As Double

The width in pixels from the start of the line to column. Does not accoutn for any horizontal padding. Assumes g is the context that will be drawn to and that the font properties have already been set.