Class UIText

All Implemented Interfaces:
EventListener, IFocusComp, IMessageBox, IComponent, ICustomDataProvider, IGProp<GProp<?>[]>, IPropCnr, IUIComp, IUICompRelativeTarget, IUIContextMenuOwner, IUIFocusComp, IUIHint, IUILabelForTarget, IUIPlainTextComponent, IUITextComponent, IVSComponentListener, IVSComponentState, IVSFieldListener, Cloneable
Direct Known Subclasses:
EUIText, UITextArea

Text UI component.
Author:
Christopher Mindus
  • Constructor Details

    • UIText

      public UIText()
      Creates the component without a name. The name must be set in all cases using the setPropertyAtom call.
    • UIText

      public UIText(Atom propertyAtom)
      Creates the component with the specified name. All system-reserved names for components begins with "$".
      Parameters:
      propertyAtom - the name of the component, unique within it's parent.
    • UIText

      public UIText(Atom propertyAtom, GProp<?>[] newValue) throws PropException
      Creates the component with the specified name, initialized to contain the GProp items. All system-reserved names for components begins with "$".
      Parameters:
      propertyAtom - The name of the component, unique within it's parent.
      newValue - The array of all properties the component should have.
      Throws:
      PropException - when at least one of the properties to initialize the component with is invalid.
  • Method Details

    • getDeviceType

      public final int getDeviceType()
      Gets the device type: -1=mobile, 0=both, 1=desktop.
      Specified by:
      getDeviceType in interface IUIComp
    • isMobileContextMenuSupported

      public boolean isMobileContextMenuSupported()
      Returns if the component can show the context menu in mobile mode.
      Specified by:
      isMobileContextMenuSupported in interface IUIContextMenuOwner
      Returns:
      Text component supports context menus for mobile.
    • getMaximalLength

      public int getMaximalLength()
      Gets the maximum length of the text field. The default value is zero (no limit).
      Returns:
      The maximum length or 0 by default.
    • setMaximalLength

      public boolean setMaximalLength(int len)
      Sets the maximum length of the text field.
      Parameters:
      len - The length to set.
      Returns:
      Successful or not.
    • setTextValue

      public boolean setTextValue(String text)
      Sets the plain text property without tags processing.

      The text length is checked against the defined "Maximal length".

      If the component is connected to a VirtualSpace Field, that text is set instead of the UI component's text.

      Parameters:
      text - The text to set in plain text (no tags and no HTML tags will be processed).
      Returns:
      true for change of text as is, false for no change, truncated text or not supported.
    • getVisualLength

      public GUnit getVisualLength()
      Gets the visual length (unit) of the entry field.
      Returns:
      The visual length or 15em by default.
    • setVisualLength

      public boolean setVisualLength(GUnit len) throws PropException
      Sets the visual length (unit) of the entry field.
      Parameters:
      len - The visual length to set.
      Returns:
      Successful or not.
      Throws:
      PropException
    • getApproximateSize

      public Size getApproximateSize()
      Returns the size of the component in pixels. The size is a calculation and does not exactly reflect the real size that may be different due to additional styles not taken into account by this method. The size is calculated from the font of the component and default or defined values (such as character length or number of lines for text area).
      Specified by:
      getApproximateSize in class UIComp
      Returns:
      The size of the component.
    • getHorizontallyExpand

      public boolean getHorizontallyExpand()
      Gets the horizontally expand option.
      Returns:
      The expand option.
    • setHorizontallyExpand

      public boolean setHorizontallyExpand(boolean on)
      Sets the horizontally expand option.
      Parameters:
      on - Set the expand option.
      Returns:
      true for value changed, false for no change.
    • getAlignTrailing

      public boolean getAlignTrailing()
      Gets the text align trailing option.
      Returns:
      The text align trailing option.
    • setAlignTrailing

      public boolean setAlignTrailing(boolean on)
      Sets the text align trailing option.
      Parameters:
      on - Set text align trailing option.
      Returns:
      true for value changed, false for no change.
    • getMinWidth

      public GUnit getMinWidth()
      Gets minimum size.
      Returns:
      The minimum size, default 1em.
    • setMinWidth

      public boolean setMinWidth(GUnit min) throws PropException
      Sets the entry field minimum width.
      Parameters:
      min - Set the minimum length.
      Returns:
      true for value changed, false for no change.
      Throws:
      PropException
    • getMaxWidth

      public GUnit getMaxWidth()
      Gets entry field maximum width.
      Returns:
      The minimum size, default 15em.
    • setMaxWidth

      public boolean setMaxWidth(GUnit max) throws PropException
      Sets the entry field maximum width.
      Parameters:
      max - Set the maximum length.
      Returns:
      true for value changed, false for no change.
      Throws:
      PropException
    • getCharUpdate

      public boolean getCharUpdate()
      Gets the character update option.
      Returns:
      The expand option.
    • setCharUpdate

      public boolean setCharUpdate(boolean on)
      Sets the character update option.
      Parameters:
      on - Set the character update option.
      Returns:
      true for value changed, false for no change.
    • getCharCase

      public int getCharCase()
      Gets the character case option.
      Returns:
      The character case option: 0=normal, 1=upper, 2=lower, 3=proper.
    • setCharCase

      public boolean setCharCase(int cc)
      Sets the character case option.
      Parameters:
      cc - The option to set: 0=normal, 1=upper, 2=lower, 3=proper.
      Returns:
      Successful or not.
    • getTrim

      public boolean getTrim()
      Gets the trim option.
      Returns:
      The trim option.
    • setTrim

      public boolean setTrim(boolean on)
      Sets the trim option.
      Parameters:
      on - Set the trim option.
      Returns:
      true for value changed, false for no change.
    • getEntryFieldType

      public EntryFieldType getEntryFieldType()
      Gets the entry field type defined.
      Returns:
      The entry field type.
    • setEntryFieldType

      public boolean setEntryFieldType(EntryFieldType type)
      Sets the entry field type.
      Parameters:
      type - The new type.
      Returns:
      true for value changed, false for no change.
    • getAutocomplete

      public String getAutocomplete()
      Gets the HTML autocomplete tokens the client sets on the input element, e.g. username, current-password, new-password, one-time-code or username webauthn for passkey autofill.
      Returns:
      The tokens, or null when not defined: the client then sets off.
    • setAutocomplete

      public boolean setAutocomplete(String tokens) throws PropException
      Sets the HTML autocomplete tokens the client sets on the input element. Browsers offer their password manager and passkey autofill only for fields carrying the matching tokens, e.g. username and current-password on a sign-in form; a field without the property keeps off.
      Parameters:
      tokens - The tokens; null or blank removes the property, which gives off on the client.
      Returns:
      true for value changed, false for no change.
      Throws:
      PropException - If the property cannot be removed.
    • getInputMode

      public String getInputMode()
      Gets the HTML inputmode the client sets on the input element: the virtual keyboard a touch device shows, whatever the field type is, e.g. numeric for a code typed in a field of the normal type.
      Returns:
      The input mode, or null when not defined: the client then sets no attribute.
    • setInputMode

      public boolean setInputMode(String mode) throws PropException
      Sets the HTML inputmode the client sets on the input element: the virtual keyboard a touch device shows.
      Parameters:
      mode - One of none, text, decimal, numeric, tel, search, email or url; null or blank removes the property, and the client then sets no attribute.
      Returns:
      true for value changed, false for no change.
      Throws:
      PropException - If the property cannot be removed.
    • getAutocapitalize

      public String getAutocapitalize()
      Gets the HTML autocapitalize the client sets on the input element: how a virtual keyboard capitalizes what is typed.
      Returns:
      The capitalization, or null when not defined: the client then sets no attribute.
    • setAutocapitalize

      public boolean setAutocapitalize(String capitalize) throws PropException
      Sets the HTML autocapitalize the client sets on the input element: how a virtual keyboard capitalizes what is typed. A user name, an e-mail address or a code takes none.
      Parameters:
      capitalize - One of none, sentences, words or characters; null or blank removes the property, and the client then sets no attribute.
      Returns:
      true for value changed, false for no change.
      Throws:
      PropException - If the property cannot be removed.
    • getSpellcheck

      public Boolean getSpellcheck()
      Gets the HTML spellcheck the client sets on the input element.
      Returns:
      Boolean.TRUE to check the spelling, Boolean.FALSE not to, or null when not defined: the client then sets no attribute and the Browser decides.
    • setSpellcheck

      public boolean setSpellcheck(Boolean check)
      Sets the HTML spellcheck the client sets on the input element. A user name, an e-mail address or a code takes false.
      Parameters:
      check - Boolean.TRUE to check the spelling, Boolean.FALSE not to; null removes the property, and the client then sets no attribute.
      Returns:
      true for value changed, false for no change.
    • getEnterKeyHint

      public String getEnterKeyHint()
      Gets the HTML enterkeyhint the client sets on the input element: the label or the icon of the Enter key of a virtual keyboard.
      Returns:
      The hint, or null when not defined: the client then sets no attribute.
    • setEnterKeyHint

      public boolean setEnterKeyHint(String hint) throws PropException
      Sets the HTML enterkeyhint the client sets on the input element: the label or the icon of the Enter key of a virtual keyboard.
      Parameters:
      hint - One of enter, done, go, next, previous, search or send; null or blank removes the property, and the client then sets no attribute.
      Returns:
      true for value changed, false for no change.
      Throws:
      PropException - If the property cannot be removed.
    • getReveal

      public boolean getReveal()
      Gets the reveal option: a field of the type EntryFieldType.PASSWORD then has a toggle button that shows the password typed and hides it again.
      Returns:
      The reveal option, false by default.
    • setReveal

      public boolean setReveal(boolean on)
      Sets the reveal option: a field of the type EntryFieldType.PASSWORD then has a toggle button that shows the password typed and hides it again. The state of the button is the client's alone, it is never sent to the server. The option does nothing on a field of another type.
      Parameters:
      on - Set the reveal option.
      Returns:
      true for value changed, false for no change.
    • getRevealShowLabel

      public String getRevealShowLabel()
      Gets the label of the reveal button while the password is hidden, the action it offers.
      Returns:
      The label, or null when not defined: the client then uses the English "Show password".
    • setRevealShowLabel

      public boolean setRevealShowLabel(String label)
      Sets the label of the reveal button while the password is hidden, the action it offers: its accessible name and its tooltip.
      Parameters:
      label - The label, e.g. "Show password"; null or blank removes the property, and the client then uses that English text.
      Returns:
      true for value changed, false for no change.
    • getRevealHideLabel

      public String getRevealHideLabel()
      Gets the label of the reveal button while the password is shown, the action it offers.
      Returns:
      The label, or null when not defined: the client then uses the English "Hide password".
    • setRevealHideLabel

      public boolean setRevealHideLabel(String label)
      Sets the label of the reveal button while the password is shown, the action it offers: its accessible name and its tooltip.
      Parameters:
      label - The label, e.g. "Hide password"; null or blank removes the property, and the client then uses that English text.
      Returns:
      true for value changed, false for no change.
    • verify

      public boolean verify(PropVerification verification)
      Verifies this text component.

      The reveal option: on a field that is not of the type password the button is never shown, a WARNING on the reveal property; on a password field without both labels the client uses its English texts, an INFO on the reveal property, since a screen reader then reads English whatever the language of the application is.

      The sign-in form: a field whose autocomplete tokens make it a sign-in field (username, current-password, new-password, one-time-code, webauthn) needs a container above it - the panel included - with the "Data entry form" option (form), which renders that container as the form element Browser password managers look for. A WARNING on the autocomplete property, since the field still works without it. A field outside a panel is not checked, as UIComp.verify(PropVerification) does not check the device type of one.

      Specified by:
      verify in interface IGProp<GProp<?>[]>
      Overrides:
      verify in class UIComp
      Parameters:
      verification - The property verification class.
      Returns:
      true if verification should proceed, false if disposed of and verification should not take place.