Class PasswordField
TextField that renders every character as a mask dot, with an optional reveal toggle.
While masked, copy/cut are blocked (the clipboard never sees the secret); paste and all editing
behave like a TextField.
The dot is drawn, not typeset; see DOT_DIAMETER. Everything else (geometry,
padding, the animated border) is inherited from TextField: this class declares no extent
of its own beyond the dot's two ratios.
The content is never shaped. shapeDisplay(java.lang.String, limn.graphics.Font) builds the masked line from
ShapedText.uniform(java.lang.String, limn.graphics.Font, float, limn.graphics.TextMetrics, long), which is one multiplication and no glyphs, so the secret never
reaches a shaper nor the memo a shaper keeps — and the caret, the click mapping, the selection
band and the painted dots then all come out of that one piece of arithmetic instead of two that
have to be kept in agreement.
-
Nested Class Summary
Nested classes/interfaces inherited from class limn.components.TextField
TextField.Validation -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanSecure text entry keeps the platform IME off (the convention ofNSSecureTextField/ES_PASSWORD): composition would echo the secret in cleartext between the mask characters, surface it in the OS candidate window, and feed it to the IME's learning dictionary.protected booleanWhether copy/cut may export the content (password fields say no).protected booleanWhile masked, word-wise caret jumps and deletes would let an observer count the words and their lengths inside the secret; modifier+arrows degrade to per-character moves until revealed.booleanWhether the characters are shown instead of the mask.protected voidpaintDisplayText(Canvas canvas, ShapedText display, float x, float baseline, TextMetrics metrics, SizeTokens t, Color ink) Paints the mask as circles on the ink box's centre line.setRevealed(boolean newRevealed) Shows/hides the real text (the optional "reveal" toggle).protected ShapedTextshapeDisplay(String text, Font font) The masked line: one dot cell per grapheme cluster, built by arithmetic and not by a shaper.Methods inherited from class limn.components.TextField
baselineOffset, caretRect, composingText, fireChange, insertText, invalidateDisplayLine, model, onChange, onCharTyped, onFocusGained, onFocusLost, onKeyEvent, onMeasure, onMouseEvent, onPaint, onPreedit, placeholder, setError, setLeadingIcon, setLeadingIcon, setPlaceholder, setPlaceholder, setPreferredWidth, setText, setTrailingButton, setTrailingButton, setValidation, showContextMenu, showContextMenuForFocus, text, validationMethods inherited from class limn.scene.Widget
add, baselineOffsetOf, children, clipboard, clipsChildren, controlSize, cursor, declaredControlSize, declaredLayoutDirection, declaredLocale, focusArrivedByTraversal, height, hitTest, imageCursor, invalidate, invalidate, isEnabled, isFocusable, isFocused, isShowing, isVisible, layoutBox, layoutDirection, locale, localToSceneX, localToSceneY, markNeedsContainedLayout, markNeedsLayout, measure, moveChild, neutralBase, onAttached, onDetached, onFileDrop, onLayout, onPaintOverlay, overlayPassesPointer, paintChildren, paintOutset, paintWidget, parent, remove, requestFocus, revealInView, scene, sceneToLocalX, sceneToLocalY, setControlSize, setCursor, setEnabled, setFocusable, setImageCursor, setInheritanceHost, setLayoutDirection, setLocale, setTooltip, setTooltip, setVisible, shapeText, textRuler, tooltip, width, x, y
-
Constructor Details
-
PasswordField
public PasswordField()
-
-
Method Details
-
isRevealed
public boolean isRevealed()Whether the characters are shown instead of the mask. -
setRevealed
Shows/hides the real text (the optional "reveal" toggle). -
shapeDisplay
The masked line: one dot cell per grapheme cluster, built by arithmetic and not by a shaper.ShapedText.uniform(java.lang.String, limn.graphics.Font, float, limn.graphics.TextMetrics, long)is what makes the whole class two overrides instead of a pair of parallel measurements. It gives a line whose index space is the model's, so the caret, the selection range and a click need no translation from source offsets to mask offsets — the count-preserving substitution the old mask string had to guarantee is not a thing that can go wrong any more, because there is no second string. And the content does not reachshape, which is the reason this override exists: a shaper resolves faces, memoizes what it was asked, and would be a place a secret comes to rest.Cells are grapheme clusters, so one dot stands for one user-perceived character and the caret can never land at a fractional dot: an astral character is one dot, not two, which also keeps the mask from leaking that a character was astral.
- Overrides:
shapeDisplayin classTextField- Parameters:
text- the model's text, which is the index space of the resultfont- the font the line is drawn in- Returns:
- the shaped display line; never null
-
paintDisplayText
protected void paintDisplayText(Canvas canvas, ShapedText display, float x, float baseline, TextMetrics metrics, SizeTokens t, Color ink) Paints the mask as circles on the ink box's centre line.The centre is
baseline - ascent + height/2, the middle of the same band the selection fill and the caret span, so the dots stay centred against any face the field's own text would use, at any step, with no per-font vertical fudge. (A dot has no baseline of its own to sit on: this is why the vertical anchor is the band and not the baseline.)- Overrides:
paintDisplayTextin classTextField- Parameters:
canvas- where to drawdisplay- the shaped display line, asTextField.shapeDisplay(java.lang.String, limn.graphics.Font)produced itx- left edge of the line, in this widget's coordinatesbaseline- the text baseline, in this widget's coordinatesmetrics- the line's vertical bandt- the size row resolved for this passink- the colour to draw in
-
allowClipboardCopy
protected boolean allowClipboardCopy()Description copied from class:TextFieldWhether copy/cut may export the content (password fields say no).- Overrides:
allowClipboardCopyin classTextField
-
allowsWordJumps
protected boolean allowsWordJumps()While masked, word-wise caret jumps and deletes would let an observer count the words and their lengths inside the secret; modifier+arrows degrade to per-character moves until revealed.- Overrides:
allowsWordJumpsin classTextField
-
acceptsTextInput
protected boolean acceptsTextInput()Secure text entry keeps the platform IME off (the convention ofNSSecureTextField/ES_PASSWORD): composition would echo the secret in cleartext between the mask characters, surface it in the OS candidate window, and feed it to the IME's learning dictionary. The scene also drops preedit events for widgets that refuse text input, so no composition can reach this field even mid-teardown. Direct key/char input (including paste) is unaffected.- Overrides:
acceptsTextInputin classTextField
-