Class PeerCaret
- All Implemented Interfaces:
Caret
Caret handed out by
JTextComponentMixin.getCaret(), so the standard Swing idiom for
repositioning a caret from inside a Document filter works as written:
int dot = field.getCaret().getDot();
field.getCaret().setDot(dot + inserted.length()); // pushes setSelectionRange to the browser
Dot, mark and the change listeners are real — they read and write the target's caret state, reach the browser, and fire on caret moves in both directions. The rest of the interface is presentation the browser owns (blink rate, visibility, painting) or machinery with no Vaadin counterpart (magic caret position): those WARN per R_vaadin_first and answer with the value a focused HTML input would give.
A null target is the deliberate fallback for a component
with no text peer under it — a Div-peered emulator, or the RTE
behind JEditorPane. Every method then WARNs and reads zero. That is the
whole point of this class existing: getCaret() returning
null put an NPE one line into every caller, which R_match_swing_errors's
warn-and-continue contract forbids.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidFires on every dot/mark move, the user's included — they arrive over the mixin'semul-selectionbridge.voidintintgetDot()intgetMark()voidbooleanbooleanvoidmoveDot(int dot) Moves the caret todotwhile leaving the mark, extending the selection.voidUser-authoredGraphicspaint is out of scope per R_match_swing_errors sub-bucket (b).voidvoidsetBlinkRate(int rate) voidsetDot(int dot) Collapses the selection and moves the caret todot.voidvoidsetSelectionVisible(boolean visible) voidsetVisible(boolean visible)
-
Constructor Details
-
PeerCaret
-
-
Method Details
-
getDot
-
getMark
-
setDot
public void setDot(int dot) Collapses the selection and moves the caret todot.- Specified by:
setDotin interfaceCaret- Throws:
IllegalArgumentException- ifdotis outside the Document, matchingJTextComponent.setCaretPosition(int)
-
moveDot
public void moveDot(int dot) Moves the caret todotwhile leaving the mark, extending the selection.- Specified by:
moveDotin interfaceCaret- Throws:
IllegalArgumentException- ifdotis outside the Document
-
isVisible
-
setVisible
public void setVisible(boolean visible) - Specified by:
setVisiblein interfaceCaret
-
isSelectionVisible
public boolean isSelectionVisible()- Specified by:
isSelectionVisiblein interfaceCaret- Returns:
- always
true— a selection in an HTML input is always rendered.
-
setSelectionVisible
public void setSelectionVisible(boolean visible) - Specified by:
setSelectionVisiblein interfaceCaret
-
getBlinkRate
public int getBlinkRate()- Specified by:
getBlinkRatein interfaceCaret- Returns:
- Swing's own default of 500ms; the real rate is the browser's and is not readable.
-
setBlinkRate
public void setBlinkRate(int rate) - Specified by:
setBlinkRatein interfaceCaret
-
addChangeListener
Fires on every dot/mark move, the user's included — they arrive over the mixin'semul-selectionbridge.- Specified by:
addChangeListenerin interfaceCaret
-
removeChangeListener
- Specified by:
removeChangeListenerin interfaceCaret
-
getMagicCaretPosition
- Specified by:
getMagicCaretPositionin interfaceCaret
-
setMagicCaretPosition
- Specified by:
setMagicCaretPositionin interfaceCaret
-
paint
-
install
-
deinstall
-