Class EditorView
- All Implemented Interfaces:
Animation, Editable, StyleListener, TextInputClient
The pure Codename One text editing surface. It renders a plain text EditorDocument with its own
Graphics code, owns the caret and selection, handles pointer and keyboard interaction, and captures
text through the low level TextInputClient contract (soft keyboard / IME) when the platform
supports it, falling back to raw keyPressed capture on physical keyboard platforms.
This class provides the shared editing behavior. Feature layers (syntax highlighting, the gutter,
styled rich text) subclass it and override #paintContent(Graphics, int, int, int, int) and the
document/measurement hooks.
-
Field Summary
Fields inherited from class Component
BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, CROSSHAIR_CURSOR, DEFAULT_CURSOR, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, E_RESIZE_CURSOR, HAND_CURSOR, LEFT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, RIGHT, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, TOP, W_RESIZE_CURSOR, WAIT_CURSORFields inherited from interface TextInputClient
KEY_BACKSPACE, KEY_COPY, KEY_CUT, KEY_DELETE, KEY_DOWN, KEY_END, KEY_ESCAPE, KEY_HOME, KEY_LEFT, KEY_PAGE_DOWN, KEY_PAGE_UP, KEY_PASTE, KEY_REDO, KEY_RIGHT, KEY_SELECT_ALL, KEY_UNDO, KEY_UP, MOD_ALT, MOD_CTRL, MOD_SHIFT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleananimate()Allows the animation to reduce "repaint" calls when it returns false.protected intReturns the base editor font size in pixels.voidblur()Relinquishes focus and stops the active platform text-input session.protected DimensionCalculates the preferred size based on component content.protected ObjectCaptures feature-layer state associated with the document for undo/redo.protected intReturns the column nearest a given content-local x pixel on a line.voidcommitText(String text) Commits final text at the caret, replacing the active selection.protected intReturns the total content height in pixels.protected intReturns the width available for text (component width minus padding and any gutter).protected voidvoiddeleteSurroundingText(int before, int after) Deletes text around the caret, the primary deletion path used by soft keyboards.protected voiddocumentEdited(int fromOffset) Hook invoked when the document is mutated atfromOffset, used by feature layers (e.g. the code editor) to invalidate cached tokenization from the affected line onward.protected voiddocumentReplaced(int start, String removed, String inserted) Hook invoked when a range is replaced, carrying the exact removed and inserted text so feature layers (e.g. the rich text editor) can keep a parallel style / block model in sync.protected voidHook invoked when the whole document is reset (e.g. by#setText(String)), so feature layers can rebuild their parallel models.voidFinalizes any active IME composition, committing the current marked text.protected intReturns the first fully or partially visible line index.protected voidCallback allowing a developer to track when the component gains focusprotected voidCallback allowing a developer to track wheh the component loses focusintReturns the current caret offset.int[]Returns the caret rectangle in absolute screen pixels{x, y, width, height}, used by the platform to anchor the IME candidate window and the selection loupe near the rendered caret.Returns the configuration describing the desired keyboard type and input behavior.protected intReturns the left inset (padding plus any gutter) at which text starts.Returns the backing document.Returns the current editing state (surrounding text, selection and composition) so the platform can seed autocorrect and prediction.protected FontReturns the font used to render text.protected intReturns the current horizontal scroll offset in pixels.protected intReturns the default height of a single visual line in pixels.protected intReturns the largest valid vertical content offset.intReturns the exclusive end offset of the selection (or the caret when none).intReturns the inclusive start offset of the selection (or the caret when none).getText()Returns the whole document text.protected intReturns the default text color used by the base renderer.intReturns the total number of UTF-16 characters in the document.getTextRange(int start, int end) Returns the text in[start, end).Returns the undo manager.protected intReturns the current vertical scroll offset in pixels.protected booleanhandleTypedText(String text) Hook giving feature layers a chance to intercept typed text before the default insertion (used by the code editor for bracket / quote auto close, tab expansion and auto indent).booleanTrue when a non empty selection exists.protected EditorHosthost()Returns the host bridge, for feature layers that need to fire editor events.voidNotifies the client that it gained the platform input focus (became first responder).voidNotifies the client that it lost the platform input focus.voidinsertText(String text) Inserts text at the caret, replacing any active selection.protected voidInvalidates the cached line layout (used by feature layers when line heights change).booleanTrue when editing is enabled.voidkeyPressed(int keyCode) If this Component is focused, the key pressed event will call this methodvoidkeyReleased(int keyCode) If this Component is focused, the key released event will call this methodvoidkeyRepeated(int keyCode) If this Component is focused, the key repeat event will call this method.protected voidlaidOut()This is a callback method to inform the Component when it's been laidout on the parent Containerprotected intlineAtContentY(int y) Returns the line index at the given content relative y pixel.protected intlineContentOffsetX(int line) Returns the extra left offset of a line's text within the content area (0 for plain text and code; the rich text editor overrides this for list bullets, indentation, block quotes and alignment so the caret and selection line up with the drawn text).protected intlineHeightAt(int line) Returns the height of the given line.protected intlineTop(int line) Returns the y pixel of the top of the given line in component local coordinates (scroll adjusted).protected intlineTopContent(int line) Returns the top y pixel of the given line relative to the content top (before scroll).protected int[]lineVisualSegments(int line, String text, int from, int to, Font f) Returns the visual selection segments for the logical range[from, to)on a line as a flat array of{x, width, x, width, ...}in content-local pixels.voidlongPointerPress(int x, int y) If this Component is focused this method is invoked when the user presses and holds the pointer on the Componentprotected intmeasureColumnX(int line, String text, int col, Font f) Returns the visual pixel x (from the start of a line) of the caret before logical columncol.voidmoveCaret(int newCaret, boolean extend) Moves the caret to a new offset, optionally extending the selection.intoffsetAtPoint(int absX, int absY) Returns the document offset nearest the given absolute screen point.voidonEditorAction(int action) Delivers the keyboard return key action (done / next / search / send) configured throughTextInputConfig.voidonKeyCommand(int command, int modifiers) Delivers a non text key command (navigation, deletion, clipboard, undo).voidThis method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.protected voidpaintBeforeContent(Graphics g, int originX, int originY, int firstLine, int lastLine, int lineHeight, Font f) Hook invoked before the visible lines are drawn, used by the code editor to paint the line number gutter.protected voidpaintComposingUnderline(Graphics g, int line, String text, int lineStart, int lineEnd, int tx, int ly, int lineHeight, Font f) Draws the IME composition (marked text) underline for the portion of the active composing range that falls on the given line.protected voidpaintContent(Graphics g, int originX, int originY, int width, int height) Paints the document content.protected voidPaints a single line of text.protected voidpaintLineDecorations(Graphics g, int line, String text, int x, int y, int lineHeight, Font f) Hook invoked after a line's text is drawn, used by the code editor to paint diagnostic squiggles.protected voidpasteClipboardData(Object data) Inserts clipboard data.voidRedoes the last undone edit.voidUndoes the last edit.voidpointerDragged(int x, int y) If this Component is focused, the pointer dragged event will call this methodvoidpointerPressed(int x, int y) If this Component is focused, the pointer pressed event will call this methodvoidpointerReleased(int x, int y) If this Component is focused, the pointer released event will call this methodint[]rectForOffset(int offset) Returns the caret rectangle for an arbitrary offset in absolute screen pixels{x, y, w, h}.protected final voidRefreshes the most recent undo unit after a feature layer finishes decorating an inserted range.voidreplaceRange(int start, int end, String text) Replaces the range[start, end)withtext(a direct, range based edit from the platform).protected voidreplaceRange(int start, int end, String text, boolean record) Replaces the range[start, end)withtext, updating the caret, history and platform input state.protected voidrestoreDocumentState(Object state) Restores a feature-layer snapshot captured by#captureDocumentState().protected voidscrollByPixels(int deltaX, int deltaY) Scrolls the content by the given pixel deltas (as delivered by the mouse wheel gesture).voidSelects the entire document.int[]selectionRects(int start, int end) Returns the selection rectangles covering[start, end)as a flat array of absolute-pixel rectangles{x, y, w, h, x, y, w, h, ...}(one entry per visual line the range spans).voidsetBackgroundColor(int color) Sets the surface background color.voidsetComposingText(String text, int relativeCaret) Updates the in progress IME composition (marked text) at the caret.voidsetEditableState(boolean editable) Enables or disables editing.voidsetFontSizeDips(int dips) Optionally overrides the editor font size in device independent pixels.voidsetSelectionColor(int color) Sets the selection highlight color.voidsetSelectionRange(int start, int end) Sets the selection to[start, end)(a caret when equal).voidReplaces the whole document text and resets the caret and history.voidsetTextColor(int color) Sets the default text color.protected booleanTrue when every line has the same height (the common case, and the fast path).Methods inherited from class Component
accessibilityChanged, accessibilityChanged, addContextMenuListener, addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addMouseWheelListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, addStylusListener, announceForAccessibility, bindProperty, blocksSideSwipe, calcScrollSize, cancelRepaints, clearClientProperties, contains, containsOrOwns, createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver, dragInitiated, drawDraggedImage, drop, fireClicked, getAbsoluteX, getAbsoluteY, getAccessibilityNode, getAccessibilityText, getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBottomGap, getBoundPropertyValue, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, getEditingDelegate, getGridPosX, getGridPosY, getHeight, getInlineAllStyles, getInlineDisabledStyles, getInlinePressedStyles, getInlineSelectedStyles, getInlineStylesTheme, getInlineUnselectedStyles, getInnerHeight, getInnerPreferredH, getInnerPreferredW, getInnerWidth, getInnerX, getInnerY, getLabelForComponent, getName, getNativeOverlay, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getOuterHeight, getOuterPreferredH, getOuterPreferredW, getOuterWidth, getOuterX, getOuterY, getOwner, getParent, getPreferredH, getPreferredSize, getPreferredSizeStr, getPreferredTabIndex, getPreferredW, getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getSemantics, getSideGap, getStyle, getTabIndex, getTensileLength, getTextSelectionSupport, getTooltip, getUIID, getUIManager, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initComponent, initCustomStyle, initDisabledStyle, initLaf, initPressedStyle, initSelectedStyle, initUnselectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditable, isEditing, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isHScrollThumbGrabbed, isHScrollThumbHover, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollableX, isScrollableY, isScrollVisible, isSelectableInteraction, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, isVScrollThumbGrabbed, isVScrollThumbHover, longKeyPress, onScrollX, onScrollY, onSetFocusable, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, paramString, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, putClientProperty, refreshTheme, refreshTheme, refreshTheme, remove, removeContextMenuListener, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removeMouseWheelListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStateChangeListener, removeStylusListener, repaint, repaint, requestFocus, resetFocusable, respondsToPointerEvents, rotation, scrollRectToVisible, scrollRectToVisible, setAccessibilityText, setAlwaysTensile, setBlockLead, setBoundPropertyValue, setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setEnabled, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden, setHideInLandscape, setHideInPortrait, setHorizontalScrollBounds, setIgnorePointerEvents, setInitialized, setInlineAllStyles, setInlineDisabledStyles, setInlinePressedStyles, setInlineSelectedStyles, setInlineStylesTheme, setInlineUnselectedStyles, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setOpaque, setOwner, setPinchBlocksDragAndDrop, setPreferredH, setPreferredSize, setPreferredSizeStr, setPreferredTabIndex, setPreferredW, setPressedStyle, setPropertyValue, setPullToRefresh, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIID, setUIIDFinal, setUnselectedStyle, setVerticalScrollBounds, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stripMarginAndPadding, styleChanged, toImage, toString, unbindProperty, updateNativeOverlay, visibleBoundsContains
-
Constructor Details
-
EditorView
Creates an editor view.
Parameters
-
host: the bridge to the owning editor component / platform input source -
codeMode: true for a code editor (autocorrect and autocapitalize disabled)
-
-
-
Method Details
-
scrollByPixels
protected void scrollByPixels(int deltaX, int deltaY) Scrolls the content by the given pixel deltas (as delivered by the mouse wheel gesture). -
getDocument
Returns the backing document. -
getUndoManager
Returns the undo manager. -
getCaretOffset
public int getCaretOffset()Returns the current caret offset. -
setBackgroundColor
public void setBackgroundColor(int color) Sets the surface background color. -
setTextColor
public void setTextColor(int color) Sets the default text color. -
setSelectionColor
public void setSelectionColor(int color) Sets the selection highlight color. -
getTextColor
protected int getTextColor()Returns the default text color used by the base renderer. -
setText
Replaces the whole document text and resets the caret and history. -
getText
Returns the whole document text. -
setEditableState
public void setEditableState(boolean editable) Enables or disables editing. -
isEditableState
public boolean isEditableState()True when editing is enabled. -
blur
public void blur()Relinquishes focus and stops the active platform text-input session. -
baseFontSizePixels
protected int baseFontSizePixels()Returns the base editor font size in pixels. -
setFontSizeDips
public void setFontSizeDips(int dips) Optionally overrides the editor font size in device independent pixels. Pass 0 to use the font supplied by the component's style (the default, which is correctly sized for the current skin). -
getEditorFont
Returns the font used to render text. By default this is the component's style font (managed and correctly sized by Codename One, and refreshed when the skin / theme reloads, which avoids stale native font handles rendering as squares). Subclasses may override to supply styled variants. -
getLineHeight
protected int getLineHeight()Returns the default height of a single visual line in pixels. -
lineHeightAt
protected int lineHeightAt(int line) Returns the height of the given line. The default is uniform (#getLineHeight()); the rich text editor overrides this for headings and font size runs. -
uniformLineHeight
protected boolean uniformLineHeight()True when every line has the same height (the common case, and the fast path). Feature layers with variable line heights override this to return false. -
invalidateLayout
protected void invalidateLayout()Invalidates the cached line layout (used by feature layers when line heights change). -
lineTopContent
protected int lineTopContent(int line) Returns the top y pixel of the given line relative to the content top (before scroll). -
contentTotalHeight
protected int contentTotalHeight()Returns the total content height in pixels. -
lineAtContentY
protected int lineAtContentY(int y) Returns the line index at the given content relative y pixel. -
getContentLeftInset
protected int getContentLeftInset()Returns the left inset (padding plus any gutter) at which text starts. -
contentWidth
protected int contentWidth()Returns the width available for text (component width minus padding and any gutter). -
hasSelection
public boolean hasSelection()True when a non empty selection exists. -
getSelectionStart
public int getSelectionStart()Returns the inclusive start offset of the selection (or the caret when none). -
getSelectionEnd
public int getSelectionEnd()Returns the exclusive end offset of the selection (or the caret when none). -
paint
Description copied from class:ComponentThis method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.
Parameters
g: the component graphics
-
longPointerPress
public void longPointerPress(int x, int y) Description copied from class:ComponentIf this Component is focused this method is invoked when the user presses and holds the pointer on the Component- Overrides:
longPointerPressin classComponent
-
paintContent
Paints the document content.
originYis already offset by the scroll position, so linenis atoriginY + n * getLineHeight(). Subclasses override to add highlighting, a gutter or styled runs but should call through for the shared caret / selection rendering, or reimplement it.Parameters
-
g: the graphics context -
originX: the x pixel at which line text starts -
originY: the y pixel of the first line (scroll adjusted) -
width: the content width -
height: the content height
-
-
paintComposingUnderline
protected void paintComposingUnderline(Graphics g, int line, String text, int lineStart, int lineEnd, int tx, int ly, int lineHeight, Font f) Draws the IME composition (marked text) underline for the portion of the active composing range that falls on the given line. The composing range is set by#setComposingText(String, int)while an input method is composing (e.g. CJK) and cleared by#finishComposing(). -
paintBeforeContent
protected void paintBeforeContent(Graphics g, int originX, int originY, int firstLine, int lastLine, int lineHeight, Font f) Hook invoked before the visible lines are drawn, used by the code editor to paint the line number gutter.originYis scroll adjusted so linensits atoriginY + n * lineHeight. -
paintLineDecorations
-
lineTop
protected int lineTop(int line) Returns the y pixel of the top of the given line in component local coordinates (scroll adjusted). -
firstVisibleLine
protected int firstVisibleLine()Returns the first fully or partially visible line index. -
getHorizontalScroll
protected int getHorizontalScroll()Returns the current horizontal scroll offset in pixels. -
getVerticalScroll
protected int getVerticalScroll()Returns the current vertical scroll offset in pixels. -
getMaximumVerticalScroll
protected int getMaximumVerticalScroll()Returns the largest valid vertical content offset. -
paintLine
Paints a single line of text. Subclasses override to add syntax coloring; the base implementation draws the whole line in the default text color.
Parameters
-
g: the graphics context -
line: the zero based line index -
text: the line text -
x: the x pixel at which the line text starts -
y: the top y pixel of the line -
lineHeight: the line height -
f: the font
-
-
offsetAtPoint
public int offsetAtPoint(int absX, int absY) Returns the document offset nearest the given absolute screen point.
Parameters
-
absX: absolute x -
absY: absolute y
- Specified by:
offsetAtPointin interfaceTextInputClient
-
-
replaceRange
Replaces the range
[start, end)withtext, updating the caret, history and platform input state.Parameters
-
start: inclusive start offset -
end: exclusive end offset -
text: the replacement text (may be empty) -
record: true to record the mutation for undo
-
-
documentEdited
protected void documentEdited(int fromOffset) Hook invoked when the document is mutated atfromOffset, used by feature layers (e.g. the code editor) to invalidate cached tokenization from the affected line onward. -
documentReplaced
Hook invoked when a range is replaced, carrying the exact removed and inserted text so feature layers (e.g. the rich text editor) can keep a parallel style / block model in sync. The default is a no-op.
Parameters
-
start: the offset at which the replacement happened -
removed: the removed text -
inserted: the inserted text
-
-
documentReset
protected void documentReset()Hook invoked when the whole document is reset (e.g. by#setText(String)), so feature layers can rebuild their parallel models. The default is a no-op. -
captureDocumentState
Captures feature-layer state associated with the document for undo/redo. Plain and code editors return null; rich editors override this to snapshot formatting, blocks, links and images. -
restoreDocumentState
Restores a feature-layer snapshot captured by#captureDocumentState(). -
refreshUndoAfterState
protected final void refreshUndoAfterState()Refreshes the most recent undo unit after a feature layer finishes decorating an inserted range. -
insertText
Inserts text at the caret, replacing any active selection. -
handleTypedText
Hook giving feature layers a chance to intercept typed text before the default insertion (used by the code editor for bracket / quote auto close, tab expansion and auto indent). Return true when the text was consumed. The default returns false.
Parameters
text: the text being typed / committed
-
host
Returns the host bridge, for feature layers that need to fire editor events. -
moveCaret
public void moveCaret(int newCaret, boolean extend) Moves the caret to a new offset, optionally extending the selection.
Parameters
-
newCaret: the target offset (clamped to the document) -
extend: true to extend the selection from the current anchor
-
-
selectAll
public void selectAll()Selects the entire document. -
copySelection
protected void copySelection() -
pasteClipboardData
Inserts clipboard data. Rich editor subclasses may override this to preserve formatting. -
lineContentOffsetX
protected int lineContentOffsetX(int line) Returns the extra left offset of a line's text within the content area (0 for plain text and code; the rich text editor overrides this for list bullets, indentation, block quotes and alignment so the caret and selection line up with the drawn text). -
measureColumnX
Returns the visual pixel x (from the start of a line) of the caret before logical columncol. For plain left-to-right text this is simply the substring width; for lines containing right-to-left or mixed (bidirectional) text it maps the logical column through the resolved visual order so the caret lines up with the reordered glyphs. The rich text editor overrides this to measure per styled run. -
columnAtX
-
lineVisualSegments
Returns the visual selection segments for the logical range[from, to)on a line as a flat array of{x, width, x, width, ...}in content-local pixels. A bidi line can yield several disjoint segments; a plain line yields a single segment. -
laidOut
-
focusGained
protected void focusGained()Description copied from class:ComponentCallback allowing a developer to track when the component gains focus- Overrides:
focusGainedin classComponent
-
focusLost
-
animate
public boolean animate()Description copied from class:ComponentAllows the animation to reduce "repaint" calls when it returns false. It is called once for every frame. Frames are defined by the
com.codename1.ui.Displayclass.Returns
true if a repaint is desired or false if no repaint is necessary
-
pointerPressed
public void pointerPressed(int x, int y) Description copied from class:ComponentIf this Component is focused, the pointer pressed event will call this method
Parameters
-
x: the pointer x coordinate -
y: the pointer y coordinate
- Overrides:
pointerPressedin classComponent
-
-
pointerDragged
public void pointerDragged(int x, int y) Description copied from class:ComponentIf this Component is focused, the pointer dragged event will call this method
Parameters
-
x: the pointer x coordinate -
y: the pointer y coordinate
- Overrides:
pointerDraggedin classComponent
-
-
pointerReleased
public void pointerReleased(int x, int y) Description copied from class:ComponentIf this Component is focused, the pointer released event will call this method
Parameters
-
x: the pointer x coordinate -
y: the pointer y coordinate
- Overrides:
pointerReleasedin classComponent
-
-
keyPressed
public void keyPressed(int keyCode) Description copied from class:ComponentIf this Component is focused, the key pressed event will call this method
Parameters
keyCode: the key code value to indicate a physical key.
- Overrides:
keyPressedin classComponent
-
keyRepeated
public void keyRepeated(int keyCode) Description copied from class:ComponentIf this Component is focused, the key repeat event will call this method.
Parameters
keyCode: the key code value to indicate a physical key.
- Overrides:
keyRepeatedin classComponent
-
keyReleased
public void keyReleased(int keyCode) Description copied from class:ComponentIf this Component is focused, the key released event will call this method
Parameters
keyCode: the key code value to indicate a physical key.
- Overrides:
keyReleasedin classComponent
-
commitText
Description copied from interface:TextInputClientCommits final text at the caret, replacing the active selection. This is the normal path for a typed character, an accepted autocorrect suggestion, dictation and paste.
Parameters
text: the committed text
- Specified by:
commitTextin interfaceTextInputClient
-
setComposingText
Description copied from interface:TextInputClientUpdates the in progress IME composition (marked text) at the caret. The composing text is not yet final and is typically rendered underlined; it is replaced on the next
#setComposingTextand finalized by#finishComposing.Parameters
-
text: the current marked text -
relativeCaret: caret position relative to the marked text (platform convention)
- Specified by:
setComposingTextin interfaceTextInputClient
-
-
finishComposing
public void finishComposing()Description copied from interface:TextInputClientFinalizes any active IME composition, committing the current marked text.- Specified by:
finishComposingin interfaceTextInputClient
-
deleteSurroundingText
public void deleteSurroundingText(int before, int after) Description copied from interface:TextInputClientDeletes text around the caret, the primary deletion path used by soft keyboards.
Parameters
-
before: number of UTF-16 units to delete before the caret -
after: number of UTF-16 units to delete after the caret
- Specified by:
deleteSurroundingTextin interfaceTextInputClient
-
-
onKeyCommand
public void onKeyCommand(int command, int modifiers) Description copied from interface:TextInputClientDelivers a non text key command (navigation, deletion, clipboard, undo). Text producing keys are delivered through
#commitTextinstead.Parameters
-
command: one of theKEY_*constants -
modifiers: a bit mask of theMOD_*constants
- Specified by:
onKeyCommandin interfaceTextInputClient
-
-
performUndo
public void performUndo()Undoes the last edit. -
performRedo
public void performRedo()Redoes the last undone edit. -
onEditorAction
public void onEditorAction(int action) Description copied from interface:TextInputClientDelivers the keyboard return key action (done / next / search / send) configured through
TextInputConfig.Parameters
action: one of theTextInputConfigACTION_*constants
- Specified by:
onEditorActionin interfaceTextInputClient
-
getEditingState
Description copied from interface:TextInputClientReturns the current editing state (surrounding text, selection and composition) so the platform can seed autocorrect and prediction. May return a window around the caret for very large documents.- Specified by:
getEditingStatein interfaceTextInputClient
-
getCaretRect
public int[] getCaretRect()Description copied from interface:TextInputClientReturns the caret rectangle in absolute screen pixels{x, y, width, height}, used by the platform to anchor the IME candidate window and the selection loupe near the rendered caret.- Specified by:
getCaretRectin interfaceTextInputClient
-
rectForOffset
public int[] rectForOffset(int offset) Description copied from interface:TextInputClientReturns the caret rectangle for an arbitrary offset in absolute screen pixels{x, y, w, h}.- Specified by:
rectForOffsetin interfaceTextInputClient
-
getTextLength
public int getTextLength()Description copied from interface:TextInputClientReturns the total number of UTF-16 characters in the document.- Specified by:
getTextLengthin interfaceTextInputClient
-
getTextRange
Description copied from interface:TextInputClientReturns the text in[start, end).- Specified by:
getTextRangein interfaceTextInputClient
-
selectionRects
public int[] selectionRects(int start, int end) Description copied from interface:TextInputClientReturns the selection rectangles covering[start, end)as a flat array of absolute-pixel rectangles{x, y, w, h, x, y, w, h, ...}(one entry per visual line the range spans).- Specified by:
selectionRectsin interfaceTextInputClient
-
replaceRange
Description copied from interface:TextInputClientReplaces the range[start, end)withtext(a direct, range based edit from the platform).- Specified by:
replaceRangein interfaceTextInputClient
-
setSelectionRange
public void setSelectionRange(int start, int end) Description copied from interface:TextInputClientSets the selection to[start, end)(a caret when equal).- Specified by:
setSelectionRangein interfaceTextInputClient
-
getConfig
Description copied from interface:TextInputClientReturns the configuration describing the desired keyboard type and input behavior.- Specified by:
getConfigin interfaceTextInputClient
-
inputFocusGained
public void inputFocusGained()Description copied from interface:TextInputClientNotifies the client that it gained the platform input focus (became first responder).- Specified by:
inputFocusGainedin interfaceTextInputClient
-
inputFocusLost
public void inputFocusLost()Description copied from interface:TextInputClientNotifies the client that it lost the platform input focus.- Specified by:
inputFocusLostin interfaceTextInputClient
-
calcPreferredSize
Description copied from class:ComponentCalculates the preferred size based on component content. This method is invoked lazily by getPreferred size.
Returns
the calculated preferred size based on component content
- Overrides:
calcPreferredSizein classComponent
-