Class TouchSelection
The touch selection chrome a text editor shows after a long press: a draggable handle at each end of the selection and a context toolbar with Copy, Cut, Paste and Select All.
The editor keeps the selection; this class only paints the chrome and says what a press
landed on. EditorView and the word processing DocumentView share it, so both editors
look and behave the same under a finger.
The host shows the chrome with setShown(true) after a long press selects a word, calls
paint after painting its content while a selection exists, and hands every press to
press before handling it itself.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceWhat the chrome needs from the editor it decorates. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intToolbar action: copy the selection.static final intToolbar action: cut the selection.static final intpressgrabbed the handle at the end of the selection.static final intpresshit nothing; the chrome was dismissed.static final intToolbar action: paste over the selection.static final intToolbar action: select everything.static final intpressgrabbed the handle at the start of the selection.static final intpresshit a toolbar button, whose action the host has already run. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
MISSED
public static final int MISSEDpresshit nothing; the chrome was dismissed.- See Also:
-
TOOLBAR
public static final int TOOLBARpresshit a toolbar button, whose action the host has already run.- See Also:
-
START_HANDLE
public static final int START_HANDLEpressgrabbed the handle at the start of the selection.- See Also:
-
END_HANDLE
public static final int END_HANDLEpressgrabbed the handle at the end of the selection.- See Also:
-
COPY
public static final int COPYToolbar action: copy the selection.- See Also:
-
CUT
public static final int CUTToolbar action: cut the selection.- See Also:
-
PASTE
public static final int PASTEToolbar action: paste over the selection.- See Also:
-
SELECT_ALL
public static final int SELECT_ALLToolbar action: select everything.- See Also:
-
-
Constructor Details
-
TouchSelection
Creates the chrome for an editor.
Parameters
host: the editor
-
-
Method Details
-
isShown
public boolean isShown()Whether the chrome is showing.
Returns
true while shown
-
setShown
public void setShown(boolean value) Shows or dismisses the chrome.
Parameters
value: true to show it
-
paint
-
press
Hit tests a press. A toolbar press runs its action; a press on neither handle nor toolbar dismisses the chrome.
Parameters
-
owner: the editor -
x: the absolute x -
y: the absolute y
Returns
MISSED,TOOLBAR,START_HANDLEorEND_HANDLE -
-