Interface CefriumRenderHandler
public interface CefriumRenderHandler
Callback interface for receiving rendered frames from a
CefriumBrowser.
Frames are delivered as BGRA pixel buffers on the UI thread.-
Method Summary
Modifier and TypeMethodDescriptiondefault voidonFocusedNodeChanged(boolean editable, String value, String placeholder, String type) Called (OSR) when the focused editable node changes, carrying the field's current value, placeholder and type read from the DOM in the renderer.default voidonImeCompositionRangeChanged(int x, int y, int width, int height) The IME composition rectangle (bounds of the first composed character, in view pixels) changed — use it to position an IME overlay.voidonPaint(int width, int height, ByteBuffer pixels) Called when a new frame has been rendered.default voidonPopupPaint(int x, int y, int width, int height, ByteBuffer pixels) Paints an OSR popup widget (e.g.default voidonPopupShow(boolean show) An OSR popup widget was shown (true) or hidden (false).default voidonPopupSize(int x, int y, int width, int height) The OSR popup widget's geometry (view pixels).default voidonQuickMenu(int x, int y, int width, int height, int editFlags, CefriumBrowser.QuickMenuCallback callback) Called (OSR) when the text-selection quick menu (Cut / Copy / Paste) should be shown -- e.g.default voidonScrollOffsetChanged(double x, double y) The page scroll offset changed (CSS pixels).default voidonTextSelectionChanged(String selectedText) The selected text changed (empty when the selection is cleared).default voidonTouchHandleStateChanged(int orientation, int x, int y, boolean enabled) Called (OSR) when a text-selection handle's state changes.default voidonVirtualKeyboardRequested(int inputMode) Called when the focused editable node changes and the on-screen keyboard should be shown or hidden (OSR mode).
-
Method Details
-
onPaint
Called when a new frame has been rendered.- Parameters:
width- Frame width in pixels.height- Frame height in pixels.pixels- Direct ByteBuffer containing BGRA pixel data (width * height * 4 bytes). Valid only during this call.
-
onVirtualKeyboardRequested
default void onVirtualKeyboardRequested(int inputMode) Called when the focused editable node changes and the on-screen keyboard should be shown or hidden (OSR mode). Mirrors CEF'sCefRenderHandler::OnVirtualKeyboardRequested.Use this to drive
InputMethodManager: show the soft keyboard (and request focus on the hosting View) when an editable is focused, hide it otherwise. Pair it with a customInputConnectionthat forwards composing and committed text toCefriumBrowser.imeSetComposition(String, int, int),CefriumBrowser.imeCommitText(String, int),CefriumBrowser.imeFinishComposingText(boolean)andCefriumBrowser.imeCancelComposition().Delivered on the Android main thread.
- Parameters:
inputMode- The requested text input mode, matching CEF'scef_text_input_mode_t(see theCefriumBrowser.TEXT_INPUT_MODE_*constants). Hide the keyboard when this equalsCefriumBrowser.TEXT_INPUT_MODE_NONE(1); any other value (includingCefriumBrowser.TEXT_INPUT_MODE_DEFAULT, which is0) means an editable is focused and the keyboard should be shown. The specific value also indicates the preferred keyboard flavour (numeric, email, ...).
-
onFocusedNodeChanged
Called (OSR) when the focused editable node changes, carrying the field's current value, placeholder and type read from the DOM in the renderer. Pairs withonVirtualKeyboardRequested(int): use this to populate a native input overlay that mirrors the focused web field.Delivered on the Android main thread.
- Parameters:
editable- True if an editable field is focused; false on blur (in which case value/placeholder/type are empty).value- The field's current value (already-typed text).placeholder- The field'splaceholderattribute, or "".type- The inputtypeattribute (e.g. "text", "password", "email"), or the tag name for non-input editables (e.g. "textarea"), or "".
-
onQuickMenu
default void onQuickMenu(int x, int y, int width, int height, int editFlags, CefriumBrowser.QuickMenuCallback callback) Called (OSR) when the text-selection quick menu (Cut / Copy / Paste) should be shown -- e.g. after long-pressing a word. Draw a small menu over your OSR view at (x,y) offering the items enabled ineditFlags(bitmask ofCefriumBrowser.QM_CAN_CUT,CefriumBrowser.QM_CAN_COPY,CefriumBrowser.QM_CAN_PASTE), then call exactly one ofcallback.cut()/copy()/paste(), orcallback.cancel()to dismiss. CEF performs the edit itself.Without handling this, OSR text selection has no copy/paste menu. Delivered on the Android main thread.
- Parameters:
x- Menu anchor x, in view pixels.y- Menu anchor y, in view pixels.width- Selection/anchor width.height- Selection/anchor height.editFlags- Bitmask of available items (QM_CAN_*).callback- Result callback (call exactly one method once).
-
onTouchHandleStateChanged
default void onTouchHandleStateChanged(int orientation, int x, int y, boolean enabled) Called (OSR) when a text-selection handle's state changes. Optional: draw draggable selection handles over your OSR view at (x,y). The quick menu (onQuickMenu) works without drawing these.- Parameters:
orientation- Handle orientation (cef_horizontal_alignment_t).x- Handle origin x, view pixels.y- Handle origin y, view pixels.enabled- Whether the handle is enabled/visible.
-
onPopupPaint
Paints an OSR popup widget (e.g. an HTML<select>dropdown). Draw these pixels over the main view at (x,y); without this, dropdowns are invisible in off-screen mode. The buffer is BGRA, valid only during this call.- Parameters:
x- Popup left, in view pixels.y- Popup top, in view pixels.width- Popup width in pixels.height- Popup height in pixels.pixels- BGRA pixel data (width * height * 4bytes).
-
onPopupShow
default void onPopupShow(boolean show) An OSR popup widget was shown (true) or hidden (false). -
onPopupSize
default void onPopupSize(int x, int y, int width, int height) The OSR popup widget's geometry (view pixels). -
onImeCompositionRangeChanged
default void onImeCompositionRangeChanged(int x, int y, int width, int height) The IME composition rectangle (bounds of the first composed character, in view pixels) changed — use it to position an IME overlay. Pairs with the OSR IME input path. -
onTextSelectionChanged
The selected text changed (empty when the selection is cleared). -
onScrollOffsetChanged
default void onScrollOffsetChanged(double x, double y) The page scroll offset changed (CSS pixels).
-