public class EditorView
ImplementsAnimation, 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.
Constructors
public EditorView(EditorHost host, boolean codeMode) | Creates an editor view. |
Methods
protected void scrollByPixels(int deltaX, int deltaY) | Scrolls the content by the given pixel deltas (as delivered by the mouse wheel gesture). |
protected final void setEditorHost(EditorHost h) | Binds the editor host after construction. |
public EditorDocument getDocument() | Returns the backing document. |
public UndoManager getUndoManager() | Returns the undo manager. |
public int getCaretOffset() | Returns the current caret offset. |
public void setBackgroundColor(int color) | Sets the surface background color. |
public void setTextColor(int color) | Sets the default text color. |
public void setSelectionColor(int color) | Sets the selection highlight color. |
protected int getTextColor() | Returns the default text color used by the base renderer. |
public void setText(String text) | Replaces the whole document text and resets the caret and history. |
public String getText() | Returns the whole document text. |
public void setEditableState(boolean editable) | Enables or disables editing. |
public boolean isEditableState() | True when editing is enabled. |
public void blur() | Relinquishes focus and stops the active platform text-input session. |
protected int baseFontSizePixels() | Returns the base editor font size in pixels. |
public void setFontSizeDips(int dips) | Optionally overrides the editor font size in device independent pixels. |
protected Font getEditorFont() | Returns the font used to render text. |
protected int getLineHeight() | Returns the default height of a single visual line in pixels. |
protected int lineHeightAt(int line) | Returns the height of the given line. |
protected boolean uniformLineHeight() | True when every line has the same height (the common case, and the fast path). |
protected void invalidateLayout() | Invalidates the cached line layout (used by feature layers when line heights change). |
protected int lineTopContent(int line) | Returns the top y pixel of the given line relative to the content top (before scroll). |
protected int contentTotalHeight() | Returns the total content height in pixels. |
protected int lineAtContentY(int y) | Returns the line index at the given content relative y pixel. |
protected int getContentLeftInset() | Returns the left inset (padding plus any gutter) at which text starts. |
protected int contentWidth() | Returns the width available for text (component width minus padding and any gutter). |
public boolean hasSelection() | True when a non empty selection exists. |
public int getSelectionStart() | Returns the inclusive start offset of the selection (or the caret when none). |
public int getSelectionEnd() | Returns the exclusive end offset of the selection (or the caret when none). |
public void paint(Graphics g) | This 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. |
public void longPointerPress(int x, int y) | If this Component is focused this method is invoked when the user presses and holds the pointer on the Component |
protected void paintContent(Graphics g, int originX, int originY, int width, int height) | Paints the document content. |
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. |
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. |
protected void paintLineDecorations(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 int lineTop(int line) | Returns the y pixel of the top of the given line in component local coordinates (scroll adjusted). |
protected int firstVisibleLine() | Returns the first fully or partially visible line index. |
protected int getHorizontalScroll() | Returns the current horizontal scroll offset in pixels. |
protected int getVerticalScroll() | Returns the current vertical scroll offset in pixels. |
protected int getMaximumVerticalScroll() | Returns the largest valid vertical content offset. |
protected void paintLine(Graphics g, int line, String text, int x, int y, int lineHeight, Font f) | Paints a single line of text. |
public int offsetAtPoint(int absX, int absY) | Returns the document offset nearest the given absolute screen point. |
protected boolean consumesRawTextInput() | This view edits text, so key codes reaching it are characters rather than commands. |
protected boolean isEditAllowed(int start, int end) | Whether the given range may be modified. |
protected void replaceRange(int start, int end, String text, boolean record) | Replaces the range [start, end) with text, updating the caret, history and platform input state. |
protected void documentEdited(int fromOffset) | Hook invoked when the document is mutated at fromOffset, used by feature layers (e.g. the code editor) to invalidate cached tokenization from the affected line onward. |
protected void documentReplaced(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 void documentReset() | Hook invoked when the whole document is reset (e.g. by #setText(String)), so feature layers can rebuild their parallel models. |
protected Object captureDocumentState() | Captures feature-layer state associated with the document for undo/redo. |
protected void restoreDocumentState(Object state) | Restores a feature-layer snapshot captured by #captureDocumentState(). |
protected final void refreshUndoAfterState() | Refreshes the most recent undo unit after a feature layer finishes decorating an inserted range. |
public void insertText(String text) | Inserts text at the caret, replacing any active selection. |
protected boolean handleTypedText(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). |
protected void handleTab(boolean dedent) | Handles a tab key press (delivered as #KEY_TAB). |
protected EditorHost host() | Returns the host bridge, for feature layers that need to fire editor events. |
public void deleteBackward() | Deletes the selection, or the character before the caret when there is none. |
public void moveCaret(int newCaret, boolean extend) | Moves the caret to a new offset, optionally extending the selection. |
public void selectAll() | Selects the entire document. |
public void copySelection() | Copies the selection to the clipboard. |
public void cutSelection() | Cuts the selection to the clipboard. |
public void pasteClipboard() | Inserts the clipboard contents at the caret. |
protected void pasteClipboardData(Object data) | Inserts clipboard data. |
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). |
protected int measureColumnX(int line, String text, int col, Font f) | Returns the visual pixel x (from the start of a line) of the caret before logical column col. |
protected int columnAtX(int line, String text, int localX, Font f) | Returns the column nearest a given content-local x pixel on a line. |
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. |
protected void laidOut() | This is a callback method to inform the Component when it’s been laidout on the parent Container |
protected void focusGained() | Callback allowing a developer to track when the component gains focus |
protected void focusLost() | Callback allowing a developer to track wheh the component loses focus |
protected void deinitialize() | Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. |
public boolean animate() | Allows the animation to reduce “repaint” calls when it returns false. |
public void pointerPressed(int x, int y) | If this Component is focused, the pointer pressed event will call this method |
public void pointerDragged(int x, int y) | If this Component is focused, the pointer dragged event will call this method |
public void pointerReleased(int x, int y) | If this Component is focused, the pointer released event will call this method |
public void keyPressed(int keyCode) | If this Component is focused, the key pressed event will call this method |
public void keyRepeated(int keyCode) | If this Component is focused, the key repeat event will call this method. |
public void keyReleased(int keyCode) | If this Component is focused, the key released event will call this method |
public void commitText(String text) | Commits final text at the caret, replacing the active selection. |
public void setComposingText(String text, int relativeCaret) | Updates the in progress IME composition (marked text) at the caret. |
public void finishComposing() | Finalizes any active IME composition, committing the current marked text. |
public void deleteSurroundingText(int before, int after) | Deletes text around the caret, the primary deletion path used by soft keyboards. |
public void onKeyCommand(int command, int modifiers) | Delivers a non text key command (navigation, deletion, clipboard, undo). |
public void performUndo() | Undoes the last edit. |
public void performRedo() | Redoes the last undone edit. |
public void onEditorAction(int action) | Delivers the keyboard return key action (done / next / search / send) configured through TextInputConfig. |
public TextInputState getEditingState() | Returns the current editing state (surrounding text, selection and composition) so the platform can seed autocorrect and prediction. |
public int[] getCaretRect() | 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. |
public int[] rectForOffset(int offset) | Returns the caret rectangle for an arbitrary offset in absolute screen pixels {x, y, w, h}. |
public int getTextLength() | Returns the total number of UTF-16 characters in the document. |
public String getTextRange(int start, int end) | Returns the text in [start, end). |
public 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). |
public void replaceRange(int start, int end, String text) | Replaces the range [start, end) with text (a direct, range based edit from the platform). |
public void setSelectionRange(int start, int end) | Sets the selection to [start, end) (a caret when equal). |
public TextInputConfig getConfig() | Returns the configuration describing the desired keyboard type and input behavior. |
public void inputFocusGained() | Notifies the client that it gained the platform input focus (became first responder). |
public void inputFocusLost() | Notifies the client that it lost the platform input focus. |
protected Dimension calcPreferredSize() | Calculates the preferred size based on component content. |
Inherited fields
From Component
DEFAULT_CURSOR, CROSSHAIR_CURSOR, TEXT_CURSOR, WAIT_CURSOR, SW_RESIZE_CURSOR, SE_RESIZE_CURSOR, NW_RESIZE_CURSOR, NE_RESIZE_CURSOR, N_RESIZE_CURSOR, S_RESIZE_CURSOR, W_RESIZE_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, MOVE_CURSOR, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_Y, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_IMMEDIATELY_DRAG_XY, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_CENTER_OFFSET, BRB_OTHER, CENTER, TOP, LEFT, BOTTOM, RIGHT, BASELINE
Inherited methods
From Component
setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, initLaf, getUIManager, getX, setX, getOuterX, getInnerX, getY, setY, getOuterY, getInnerY, isVisible, setVisible, getClientProperty, stripMarginAndPadding, clearClientProperties, putClientProperty, getDirtyRegion, setDirtyRegion, isOpaque, setOpaque, getWidth, setWidth, getOuterWidth, getInnerWidth, getHeight, setHeight, getOuterHeight, getInnerHeight, isDragRegion, getDragRegionStatus, getBaseline, getBaselineResizeBehavior, getPreferredSizeStr, setPreferredSizeStr, getPreferredSize, setPreferredSize, getScrollDimension, calcScrollSize, setScrollSize, getPreferredW, setPreferredW, getPreferredH, setPreferredH, getOuterPreferredH, getInnerPreferredH, getOuterPreferredW, getInnerPreferredW, setSize, getUIID, setUIID, setUIIDFinal, setUIID, getInlineAllStyles, setInlineAllStyles, getInlineSelectedStyles, setInlineSelectedStyles, getInlineUnselectedStyles, setInlineUnselectedStyles, getInlineDisabledStyles, setInlineDisabledStyles, getInlinePressedStyles, setInlinePressedStyles, remove, getParent, getOwner, setOwner, isOwnedBy, containsOrOwns, addFocusListener, removeFocusListener, addScrollListener, removeScrollListener, fireClicked, isSelectableInteraction, getSelectCommandText, setSelectCommandText, getLabelForComponent, setLabelForComponent, paintBackgrounds, paintShadows, getAbsoluteX, getAbsoluteY, isInClippingRegion, paintIntersectingComponentsAbove, paintScrollbars, paintScrollbarX, getScrollOpacity, getSelectedRect, paintScrollbarY, paintComponent, paintComponent, getBorder, getScrollable, paintBackground, isScrollable, isScrollableX, isScrollableY, getScrollX, setScrollX, getScrollY, setScrollY, onScrollX, onScrollY, getDraggedx, getDraggedy, getBottomGap, getSideGap, contains, visibleBoundsContains, hasFixedPreferredSize, getBounds, getBounds, getVisibleBounds, getVisibleBounds, isFocusable, setFocusable, onSetFocusable, resetFocusable, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, setShouldCalcPreferredSize, handlesInput, setHandlesInput, hasFocus, setFocus, getComponentForm, getTopLevelContainer, repaint, repaint, longKeyPress, registerForAnimation, deregisterFromAnimation, getAnimationManager, getScrollAnimationSpeed, setScrollAnimationSpeed, isBlockLead, setBlockLead, isIgnorePointerEvents, setIgnorePointerEvents, isRippleEffect, setRippleEffect, getInlineStylesTheme, setInlineStylesTheme, shouldRenderComponentSelection, isHideInLandscape, setHideInLandscape, createStyleAnimation, isSmoothScrolling, setSmoothScrolling, pointerHover, stopScrollMomentum, pointerHoverReleased, pointerHoverPressed, pinch, pinchReleased, pinch, rotation, isPinchBlocksDragAndDrop, setPinchBlocksDragAndDrop, pointerDragged, getDragImage, getDragTransparency, setDragTransparency, toImage, dragInitiated, drawDraggedImage, draggingOver, dragEnter, dragExit, drop, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, isStickyDrag, pointerPressed, isDragAndDropOperation, pointerReleased, setVerticalScrollBounds, setHorizontalScrollBounds, isVScrollThumbGrabbed, isHScrollThumbGrabbed, isVScrollThumbHover, isHScrollThumbHover, isTensileDragEnabled, setTensileDragEnabled, getTextSelectionSupport, addDropListener, removeDropListener, addDragOverListener, removeDragOverListener, isNativeDragSource, setNativeDragSource, getNativeDragOperation, setNativeDragOperation, createNativeDragOperation, isNativeDropTarget, setNativeDropTarget, getAcceptedDropMimeTypes, setAcceptedDropMimeTypes, getAcceptedDropActions, setAcceptedDropActions, canAcceptNativeDrop, nativeDragEnter, nativeDragOver, nativeDragExit, nativeDrop, addNativeDropListener, removeNativeDropListener, addNativeDragOverListener, removeNativeDragOverListener, dragFinished, addDragFinishedListener, addStateChangeListener, removeStateChangeListener, addPointerPressedListener, addLongPressListener, addContextMenuListener, removeContextMenuListener, addMouseWheelListener, removeMouseWheelListener, addStylusListener, removeStylusListener, mouseWheel, paintRippleOverlay, removePointerPressedListener, removeLongPressListener, removeDragFinishedListener, addPointerReleasedListener, removePointerReleasedListener, addPointerDraggedListener, removePointerDraggedListener, getDragSpeed, getStyle, getPressedStyle, setPressedStyle, initUnselectedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, paramString, refreshTheme, refreshTheme, refreshTheme, isDragActivated, getGridPosY, getGridPosX, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, setCellRenderer, isScrollVisible, setScrollVisible, setIsScrollVisible, startEditingAsync, stopEditing, isEditing, isEditable, initComponent, isInitialized, setInitialized, styleChanged, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, isEnabled, setEnabled, getName, setName, initCustomStyle, deinitializeCustomStyle, isRTL, setRTL, isTactileTouch, isTactileTouch, setTactileTouch, getPropertyNames, getPropertyTypes, getPropertyTypeNames, getPropertyValue, setPropertyValue, paintLockRelease, paintLock, isSnapToGrid, setSnapToGrid, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, blocksSideSwipe, isFlatten, setFlatten, getTensileLength, setTensileLength, isGrabsPointerEvents, setGrabsPointerEvents, getScrollOpacityChangeSpeed, setScrollOpacityChangeSpeed, growShrink, isAlwaysTensile, setAlwaysTensile, isDraggable, setDraggable, isDropTarget, setDropTarget, isChildOf, isHideInPortrait, setHideInPortrait, cancelRepaints, getBindablePropertyNames, getBindablePropertyTypes, bindProperty, unbindProperty, getBoundPropertyValue, setBoundPropertyValue, getCloudBoundProperty, setCloudBoundProperty, getCloudDestinationProperty, setCloudDestinationProperty, getComponentState, setComponentState, setHidden, isHidden, setHidden, isHidden, announceForAccessibility, getAccessibilityText, setAccessibilityText, getSemantics, getAccessibilityNode, accessibilityChanged, accessibilityChanged, getTooltip, setTooltip
Constructor details
EditorView
public EditorView(EditorHost host, boolean codeMode)Parameters
hostEditorHost- the bridge to the owning editor component / platform input source
codeModeboolean- true for a code editor (autocorrect and autocapitalize disabled)
Method details
scrollByPixels
protected void scrollByPixels(int deltaX, int deltaY)setEditorHost
protected final void setEditorHost(EditorHost h)com.codename1.ui.EditField), which cannot pass this to the constructor.getDocument
public EditorDocument getDocument()getUndoManager
public UndoManager getUndoManager()getCaretOffset
public int getCaretOffset()setBackgroundColor
public void setBackgroundColor(int color)setTextColor
public void setTextColor(int color)setSelectionColor
public void setSelectionColor(int color)getTextColor
protected int getTextColor()setText
public void setText(String text)getText
public String getText()setEditableState
public void setEditableState(boolean editable)isEditableState
public boolean isEditableState()blur
public void blur()baseFontSizePixels
protected int baseFontSizePixels()setFontSizeDips
public void setFontSizeDips(int dips)getEditorFont
protected Font getEditorFont()getLineHeight
protected int getLineHeight()lineHeightAt
protected int lineHeightAt(int line)#getLineHeight()); the rich text
editor overrides this for headings and font size runs.uniformLineHeight
protected boolean uniformLineHeight()invalidateLayout
protected void invalidateLayout()lineTopContent
protected int lineTopContent(int line)contentTotalHeight
protected int contentTotalHeight()lineAtContentY
protected int lineAtContentY(int y)getContentLeftInset
protected int getContentLeftInset()contentWidth
protected int contentWidth()hasSelection
public boolean hasSelection()getSelectionStart
public int getSelectionStart()getSelectionEnd
public int getSelectionEnd()paint
public void paint(Graphics g)Parameters
gGraphics- the component graphics
longPointerPress
public void longPointerPress(int x, int y)paintContent
protected void paintContent(Graphics g, int originX, int originY, int width, int height)originY is already offset by the scroll position, so line n is at
originY + 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
gGraphics- the graphics context
originXint- the x pixel at which line text starts
originYint- the y pixel of the first line (scroll adjusted)
widthint- the content width
heightint- 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)#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)originY is scroll adjusted so line n sits at originY + n * lineHeight.paintLineDecorations
protected void paintLineDecorations(Graphics g, int line, String text, int x, int y, int lineHeight, Font f)lineTop
protected int lineTop(int line)firstVisibleLine
protected int firstVisibleLine()getHorizontalScroll
protected int getHorizontalScroll()getVerticalScroll
protected int getVerticalScroll()getMaximumVerticalScroll
protected int getMaximumVerticalScroll()paintLine
protected void paintLine(Graphics g, int line, String text, int x, int y, int lineHeight, Font f)Parameters
gGraphics- the graphics context
lineint- the zero based line index
textString- the line text
xint- the x pixel at which the line text starts
yint- the top y pixel of the line
lineHeightint- the line height
fFont- the font
offsetAtPoint
public int offsetAtPoint(int absX, int absY)Parameters
absXint- absolute x
absYint- absolute y
consumesRawTextInput
protected boolean consumesRawTextInput()This view edits text, so key codes reaching it are characters rather than commands.
Only while it is editable. A read only view declines the insert in keyReleased, so
claiming the code anyway took a colliding soft key away from the menu bar and then did
nothing with it – the command was silently lost.
Returns
isEditAllowed
protected boolean isEditAllowed(int start, int end)#replaceRange(int, int, String, boolean).Parameters
startint- inclusive start offset of the edit
endintexclusive end offset of the edit
Returns: true when the edit may proceed
replaceRange
protected void replaceRange(int start, int end, String text, boolean record)[start, end) with text, updating the caret, history and platform input
state.Parameters
startint- inclusive start offset
endint- exclusive end offset
textString- the replacement text (may be empty)
recordboolean- true to record the mutation for undo
documentEdited
protected void documentEdited(int fromOffset)fromOffset, used by feature layers (e.g. the code
editor) to invalidate cached tokenization from the affected line onward.documentReplaced
protected void documentReplaced(int start, String removed, String inserted)Parameters
startint- the offset at which the replacement happened
removedString- the removed text
insertedString- the inserted text
documentReset
protected void documentReset()#setText(String)), so feature layers can
rebuild their parallel models. The default is a no-op.captureDocumentState
protected Object captureDocumentState()restoreDocumentState
protected void restoreDocumentState(Object state)#captureDocumentState().refreshUndoAfterState
protected final void refreshUndoAfterState()insertText
public void insertText(String text)handleTypedText
protected boolean handleTypedText(String text)Parameters
textString- the text being typed / committed
handleTab
protected void handleTab(boolean dedent)#KEY_TAB). Feature layers override this for indent /
dedent behavior. The default inserts a tab character on a plain tab and does nothing on a
dedent (a plain editor has no indentation to remove).Parameters
dedentboolean- true when shift was held (shift-tab)
host
protected EditorHost host()deleteBackward
public void deleteBackward()#deleteSurroundingText(int, int).moveCaret
public void moveCaret(int newCaret, boolean extend)Parameters
newCaretint- the target offset (clamped to the document)
extendboolean- true to extend the selection from the current anchor
selectAll
public void selectAll()copySelection
public void copySelection()cutSelection
public void cutSelection()#copySelection() for why this is public.pasteClipboard
public void pasteClipboard()#copySelection() for why this is public.pasteClipboardData
protected void pasteClipboardData(Object data)lineContentOffsetX
protected int lineContentOffsetX(int line)measureColumnX
protected int measureColumnX(int line, String text, int col, Font f)col.
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
protected int columnAtX(int line, String text, int localX, Font f)lineVisualSegments
protected int[] lineVisualSegments(int line, String text, int from, int to, Font f)[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
protected void laidOut()focusGained
protected void focusGained()focusLost
protected void focusLost()deinitialize
protected void deinitialize()animate
public boolean animate()com.codename1.ui.Display class.Returns
pointerPressed
public void pointerPressed(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
pointerDragged
public void pointerDragged(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
pointerReleased
public void pointerReleased(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
keyPressed
public void keyPressed(int keyCode)Parameters
keyCodeint- the key code value to indicate a physical key.
keyRepeated
public void keyRepeated(int keyCode)Parameters
keyCodeint- the key code value to indicate a physical key.
keyReleased
public void keyReleased(int keyCode)Parameters
keyCodeint- the key code value to indicate a physical key.
commitText
public void commitText(String text)Parameters
textString- the committed text
setComposingText
public void setComposingText(String text, int relativeCaret)#setComposingText and
finalized by #finishComposing.Parameters
textString- the current marked text
relativeCaretint- caret position relative to the marked text (platform convention)
finishComposing
public void finishComposing()deleteSurroundingText
public void deleteSurroundingText(int before, int after)Parameters
beforeint- number of UTF-16 units to delete before the caret
afterint- number of UTF-16 units to delete after the caret
onKeyCommand
public void onKeyCommand(int command, int modifiers)#commitText instead.Parameters
commandint- one of the
KEY_*constants modifiersint- a bit mask of the
MOD_*constants
performUndo
public void performUndo()performRedo
public void performRedo()onEditorAction
public void onEditorAction(int action)TextInputConfig.Parameters
actionint- one of the
TextInputConfigACTION_*constants
getEditingState
public TextInputState getEditingState()getCaretRect
public int[] getCaretRect(){x, y, width, height}, used by the
platform to anchor the IME candidate window and the selection loupe near the rendered caret.rectForOffset
public int[] rectForOffset(int offset){x, y, w, h}.getTextLength
public int getTextLength()getTextRange
public String getTextRange(int start, int end)[start, end).selectionRects
public int[] selectionRects(int start, int end)[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).replaceRange
public void replaceRange(int start, int end, String text)[start, end) with text (a direct, range based edit from the platform).setSelectionRange
public void setSelectionRange(int start, int end)[start, end) (a caret when equal).getConfig
public TextInputConfig getConfig()inputFocusGained
public void inputFocusGained()inputFocusLost
public void inputFocusLost()calcPreferredSize
protected Dimension calcPreferredSize()