public abstract class AbstractEditorComponent

  1. Object
  2. Component
  3. Container
  4. AbstractEditorComponent

ImplementsAnimation, Editable, EditorHost, Iterable<Component>, StyleListener

Known subtypesCodeEditor, RichTextArea

Base class for the pure Codename One visual editors (rich text and code).

The editor components are designed around a semantic command channel rather than a single hard-coded implementation. Every concrete editor (RichTextArea, CodeEditor) speaks to its backend exclusively through #command(String, String), #query(String, String, SuccessCallback) and the inbound #onEditorEvent(String, String) dispatch. Two interchangeable backends honor that channel:

  1. The pure Codename One text engine (com.codename1.ui.editor) which renders the document itself with Graphics/Font and binds to the platform text input source (soft keyboard, hardware keyboard and IME) where available, falling back to the raw physical-keyboard path elsewhere. This is the default on every port.
  2. An optional native backend supplied by the platform port (see com.codename1.impl.CodenameOneImplementation#createNativeEditorPeer(AbstractEditorComponent, String)). When a port returns a non-null native peer the editor drives it through editorPeerCommand / editorPeerQuery instead of the pure engine, allowing a platform to provide a genuinely native experience.

All backends are addressed with the same vocabulary so concrete editors never need to know which one is active.

Constructors

protected AbstractEditorComponent(String uiid)Creates the editor and begins asynchronous backend initialization.

Methods

public void fireEditorEvent(String type, String value)Entry point invoked by native editor peers to deliver events back to Codename One.
protected void command(String name, String arg)Sends a one way command to the active backend.
protected void query(String name, String arg, SuccessCallback<String> callback)Queries the active backend for a string value asynchronously.
public void onReady(Runnable r)Runs the supplied task once the editor backend is ready, or immediately if it already is.
public boolean isEditorReady()Returns true once the underlying editor backend has finished initializing and is ready to accept commands.
public boolean isNativeEditor()True when a platform supplied native editor backend is in use, false for the pure backend.
public void addChangeListener(ActionListener l)Adds a listener notified whenever the editor content changes.
public void removeChangeListener(ActionListener l)Removes a previously registered change listener.
public void addReadyListener(ActionListener l)Adds a listener notified once when the editor backend becomes ready.
public void removeReadyListener(ActionListener l)Removes a previously registered ready listener.
public void setEditable(boolean editable)Enables or disables editing.
public boolean isEditable()Returns true if the editor currently allows editing.
public void focusEditor()Requests keyboard focus for the editing surface, showing the virtual keyboard on touch devices.
public void blurEditor()Removes keyboard focus from the editing surface, hiding the virtual keyboard on touch devices.
public boolean isTextInputSupported()True when the platform can bind a low level text input client (see com.codename1.impl.CodenameOneImplementation#isTextInputSupported).
public Object startTextInput(TextInputClient client, TextInputConfig config)Binds the client to the platform text input source and returns an opaque handle.
public void updateTextInputState(Object handle, TextInputState state)Pushes the client’s editing state down to the bound input source.
public void stopTextInput(Object handle)Unbinds a previously bound text input client.
public void editorChanged()Notifies the owning editor that the document content changed so it can fire its change listeners.

Inherited fields

Inherited methods

From Container

encloseIn, encloseIn, initLaf, getUIManager, setUIManager, isSurface, add, addAll, add, add, add, add, add, getLeadComponent, setLeadComponent, getLeadParent, keyPressed, keyReleased, getLayout, setLayout, invalidate, setShouldLayout, setShouldCalcPreferredSize, getLayoutWidth, getLayoutHeight, applyRTL, constrainWidthWhenScrollable, constrainHeightWhenScrollable, addComponent, addComponent, addComponent, addComponent, replaceAndWait, replaceAndWait, replace, replaceAndWait, replace, createReplaceTransition, isEnabled, setEnabled, removeComponent, cancelRepaints, flushReplace, removeAll, revalidateWithAnimationSafety, revalidate, revalidateLater, forceRevalidate, clearClientProperties, paint, paintGlass, layoutContainer, isSafeArea, setSafeArea, isSafeAreaRoot, getSafeAreaRoot, setSafeAreaRoot, getComponentCount, getComponentAt, getComponentIndex, contains, scrollComponentToVisible, getClosestComponentTo, getResponderAt, getComponentAt, findDropTargetAt, pointerPressed, calcPreferredSize, paramString, refreshTheme, isScrollableX, setScrollableX, isScrollableY, setScrollableY, getSideGap, getBottomGap, setScrollable, setCellRenderer, getScrollIncrement, setScrollIncrement, findFirstFocusable, dragInitiated, fireClicked, isSelectableInteraction, getGridPosY, paintComponentBackground, getGridPosX, animateHierarchyAndWait, createAnimateHierarchy, animateHierarchy, animateHierarchyFadeAndWait, createAnimateHierarchyFade, animateHierarchyFade, animateLayoutFadeAndWait, createAnimateLayoutFadeAndWait, animateLayoutFade, createAnimateLayoutFade, animateLayoutAndWait, animateLayout, updateTabIndices, createAnimateLayout, drop, createAnimateMotion, morph, morphAndWait, animateUnlayout, animateUnlayoutAndWait, createAnimateUnlayout, getChildrenAsList, iterator, iterator

From Component

setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, getX, setX, getOuterX, getInnerX, getY, setY, getOuterY, getInnerY, isVisible, setVisible, getClientProperty, stripMarginAndPadding, 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, getSelectCommandText, setSelectCommandText, getLabelForComponent, setLabelForComponent, focusGained, focusLost, paintBackgrounds, paintShadows, getAbsoluteX, getAbsoluteY, isInClippingRegion, paintIntersectingComponentsAbove, paintScrollbars, paintScrollbarX, getScrollOpacity, getSelectedRect, paintScrollbarY, paintComponent, paintComponent, getBorder, getScrollable, paintBackground, isScrollable, getScrollX, setScrollX, getScrollY, setScrollY, onScrollX, onScrollY, getDraggedx, getDraggedy, contains, visibleBoundsContains, hasFixedPreferredSize, getBounds, getBounds, getVisibleBounds, getVisibleBounds, isFocusable, setFocusable, onSetFocusable, resetFocusable, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, handlesInput, setHandlesInput, consumesRawTextInput, hasFocus, setFocus, getComponentForm, getTopLevelContainer, repaint, repaint, longKeyPress, keyRepeated, 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, drawDraggedImage, draggingOver, dragEnter, dragExit, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, pointerDragged, isStickyDrag, pointerPressed, isDragAndDropOperation, pointerReleased, longPointerPress, 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, refreshTheme, refreshTheme, isDragActivated, animate, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, isScrollVisible, setScrollVisible, setIsScrollVisible, startEditingAsync, stopEditing, isEditing, laidOut, deinitialize, initComponent, isInitialized, setInitialized, styleChanged, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, 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, 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

AbstractEditorComponent

protected AbstractEditorComponent(String uiid)
Creates the editor and begins asynchronous backend initialization.

Parameters

uiid String
the UIID applied to the editor container

Method details

fireEditorEvent

public void fireEditorEvent(String type, String value)
Entry point invoked by native editor peers to deliver events back to Codename One. This routes to the same dispatch path used by the browser message bridge so subclasses handle events uniformly regardless of backend.

Parameters

type String
the event type
value String
optional payload, may be null

command

protected void command(String name, String arg)
Sends a one way command to the active backend. If the backend is not ready yet the command is queued and replayed once initialization completes.

Parameters

name String
the semantic command name understood by both backends
arg String
an optional string argument, may be null

query

protected void query(String name, String arg, SuccessCallback<String> callback)
Queries the active backend for a string value asynchronously. The callback is always invoked on the EDT. If the backend is not ready the query is deferred until it is.

Parameters

name String
the semantic query name understood by both backends
arg String
an optional string argument, may be null
callback SuccessCallback<String>
receives the query result

onReady

public void onReady(Runnable r)
Runs the supplied task once the editor backend is ready, or immediately if it already is.

Parameters

r Runnable
the task to run on the EDT when the editor is ready

isEditorReady

public boolean isEditorReady()
Returns true once the underlying editor backend has finished initializing and is ready to accept commands.

isNativeEditor

public boolean isNativeEditor()
True when a platform supplied native editor backend is in use, false for the pure backend.

addChangeListener

public void addChangeListener(ActionListener l)
Adds a listener notified whenever the editor content changes.

Parameters

l ActionListener
the change listener

removeChangeListener

public void removeChangeListener(ActionListener l)
Removes a previously registered change listener.

Parameters

l ActionListener
the change listener

addReadyListener

public void addReadyListener(ActionListener l)
Adds a listener notified once when the editor backend becomes ready.

Parameters

l ActionListener
the ready listener

removeReadyListener

public void removeReadyListener(ActionListener l)
Removes a previously registered ready listener.

Parameters

l ActionListener
the ready listener

setEditable

public void setEditable(boolean editable)
Enables or disables editing. A disabled editor still displays content but rejects input.

Parameters

editable boolean
true to allow editing

isEditable

public boolean isEditable()
Returns true if the editor currently allows editing.

focusEditor

public void focusEditor()
Requests keyboard focus for the editing surface, showing the virtual keyboard on touch devices.

blurEditor

public void blurEditor()
Removes keyboard focus from the editing surface, hiding the virtual keyboard on touch devices.

isTextInputSupported

public boolean isTextInputSupported()
True when the platform can bind a low level text input client (see com.codename1.impl.CodenameOneImplementation#isTextInputSupported).

startTextInput

public Object startTextInput(TextInputClient client, TextInputConfig config)
Binds the client to the platform text input source and returns an opaque handle.

updateTextInputState

public void updateTextInputState(Object handle, TextInputState state)
Pushes the client’s editing state down to the bound input source.

stopTextInput

public void stopTextInput(Object handle)
Unbinds a previously bound text input client.

editorChanged

public void editorChanged()
Notifies the owning editor that the document content changed so it can fire its change listeners.