public abstract class 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:
- The pure Codename One text engine (
com.codename1.ui.editor) which renders the document itself withGraphics/Fontand 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. - 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 througheditorPeerCommand/editorPeerQueryinstead 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
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 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)Parameters
uiidString- the UIID applied to the editor container
Method details
fireEditorEvent
public void fireEditorEvent(String type, String value)Parameters
typeString- the event type
valueString- optional payload, may be null
command
protected void command(String name, String arg)Parameters
nameString- the semantic command name understood by both backends
argString- an optional string argument, may be null
query
protected void query(String name, String arg, SuccessCallback<String> callback)Parameters
nameString- the semantic query name understood by both backends
argString- an optional string argument, may be null
callbackSuccessCallback<String>- receives the query result
onReady
public void onReady(Runnable r)Parameters
rRunnable- the task to run on the EDT when the editor is ready
isEditorReady
public boolean isEditorReady()isNativeEditor
public boolean isNativeEditor()addChangeListener
public void addChangeListener(ActionListener l)Parameters
lActionListener- the change listener
removeChangeListener
public void removeChangeListener(ActionListener l)Parameters
lActionListener- the change listener
addReadyListener
public void addReadyListener(ActionListener l)Parameters
lActionListener- the ready listener
removeReadyListener
public void removeReadyListener(ActionListener l)Parameters
lActionListener- the ready listener
setEditable
public void setEditable(boolean editable)Parameters
editableboolean- true to allow editing
isEditable
public boolean isEditable()focusEditor
public void focusEditor()blurEditor
public void blurEditor()isTextInputSupported
public boolean isTextInputSupported()com.codename1.impl.CodenameOneImplementation#isTextInputSupported).startTextInput
public Object startTextInput(TextInputClient client, TextInputConfig config)updateTextInputState
public void updateTextInputState(Object handle, TextInputState state)stopTextInput
public void stopTextInput(Object handle)editorChanged
public void editorChanged()