# Class AbstractEditorComponent

java.lang.Object
com.codename1.ui.Component
com.codename1.ui.Container
com.codename1.ui.AbstractEditorComponent

All Implemented Interfaces:
  `Animation, Editable, EditorHost, StyleListener, Iterable<Component>`

Direct Known Subclasses:
  `CodeEditor, RichTextArea`

public abstract class AbstractEditorComponent extends Container implements EditorHost

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.

- ## 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_CURSOR`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `AbstractEditorComponent(String uiid)`
  Creates the editor and begins asynchronous backend initialization.

- ## Method Summary

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

  ### Methods inherited from class Container

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

  ### Methods inherited from class Component

  `accessibilityChanged, accessibilityChanged, addContextMenuListener, addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addMouseWheelListener, addNativeDragOverListener, addNativeDropListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, addStylusListener, animate, announceForAccessibility, bindProperty, blocksSideSwipe, calcScrollSize, canAcceptNativeDrop, consumesRawTextInput, contains, containsOrOwns, createNativeDragOperation, createStyleAnimation, deinitialize, deinitializeCustomStyle, deregisterFromAnimation, dragEnter, dragExit, dragFinished, draggingOver, drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAcceptedDropActions, getAcceptedDropMimeTypes, getAccessibilityNode, getAccessibilityText, getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBoundPropertyValue, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, getEditingDelegate, getHeight, getInlineAllStyles, getInlineDisabledStyles, getInlinePressedStyles, getInlineSelectedStyles, getInlineStylesTheme, getInlineUnselectedStyles, getInnerHeight, getInnerPreferredH, getInnerPreferredW, getInnerWidth, getInnerX, getInnerY, getLabelForComponent, getName, getNativeDragOperation, 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, getStyle, getTabIndex, getTensileLength, getTextSelectionSupport, getTooltip, getTopLevelContainer, getUIID, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initComponent, initCustomStyle, initDisabledStyle, initPressedStyle, initSelectedStyle, initUnselectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditing, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isHScrollThumbGrabbed, isHScrollThumbHover, isIgnorePointerEvents, isInClippingRegion, isInitialized, isNativeDragSource, isNativeDropTarget, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, isVScrollThumbGrabbed, isVScrollThumbHover, keyRepeated, laidOut, longKeyPress, longPointerPress, nativeDragEnter, nativeDragExit, nativeDragOver, nativeDrop, onScrollX, onScrollY, onSetFocusable, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, refreshTheme, registerForAnimation, remove, removeContextMenuListener, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removeMouseWheelListener, removeNativeDragOverListener, removeNativeDropListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStateChangeListener, removeStylusListener, repaint, repaint, requestFocus, resetFocusable, respondsToPointerEvents, rotation, scrollRectToVisible, scrollRectToVisible, setAcceptedDropActions, setAcceptedDropMimeTypes, setAccessibilityText, setAlwaysTensile, setBlockLead, setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden, setHideInLandscape, setHideInPortrait, setHorizontalScrollBounds, setIgnorePointerEvents, setInitialized, setInlineAllStyles, setInlineDisabledStyles, setInlinePressedStyles, setInlineSelectedStyles, setInlineStylesTheme, setInlineUnselectedStyles, setIsScrollVisible, setLabelForComponent, setName, setNativeDragOperation, setNativeDragSource, setNativeDropTarget, 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, 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`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface Iterable

  `forEach`

- ## Constructor Details

  - ### AbstractEditorComponent

    protected AbstractEditorComponent(String uiid)

    Creates the editor and begins asynchronous backend initialization.

    ###### Parameters

    - `uiid`: 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`: the event type

    - `value`: optional payload, may be null

    Specified by:
      `fireEditorEvent` in interface `EditorHost`

  - ### 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`: the semantic command name understood by both backends

    - `arg`: 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`: the semantic query name understood by both backends

    - `arg`: an optional string argument, may be null

    - `callback`: 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`: 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`: the change listener

  - ### removeChangeListener

    public void removeChangeListener(ActionListener l)

    Removes a previously registered change listener.

    ###### Parameters

    - `l`: the change listener

  - ### addReadyListener

    public void addReadyListener(ActionListener l)

    Adds a listener notified once when the editor backend becomes ready.

    ###### Parameters

    - `l`: the ready listener

  - ### removeReadyListener

    public void removeReadyListener(ActionListener l)

    Removes a previously registered ready listener.

    ###### Parameters

    - `l`: the ready listener

  - ### setEditable

    public void setEditable(boolean editable)

    Enables or disables editing. A disabled editor still displays content but rejects input.

    ###### Parameters

    - `editable`: true to allow editing

  - ### isEditable

    public boolean isEditable()
    Returns true if the editor currently allows editing.
    Specified by:
      `isEditable` in interface `Editable`
    Overrides:
      `isEditable` in class `Component`

  - ### 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`).
    Specified by:
      `isTextInputSupported` in interface `EditorHost`

  - ### startTextInput

    public Object startTextInput(TextInputClient client, TextInputConfig config)
    Binds the client to the platform text input source and returns an opaque handle.
    Specified by:
      `startTextInput` in interface `EditorHost`

  - ### updateTextInputState

    public void updateTextInputState(Object handle, TextInputState state)
    Pushes the client's editing state down to the bound input source.
    Specified by:
      `updateTextInputState` in interface `EditorHost`

  - ### stopTextInput

    public void stopTextInput(Object handle)
    Unbinds a previously bound text input client.
    Specified by:
      `stopTextInput` in interface `EditorHost`

  - ### editorChanged

    public void editorChanged()
    Notifies the owning editor that the document content changed so it can fire its change listeners.
    Specified by:
      `editorChanged` in interface `EditorHost`