Interface InputElement
- All Superinterfaces:
DomQueryable
,Element
,EventTarget
,Node
An element that can take in a player's input
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Default placeholder value returned bygetPlaceholder()
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Input elements cannot have child nodes.@NotNull String
Get the element's placeholder, or a fallback value, if not set.Get theAttributes.PROMPT
attribute value.@NotNull InputElement.InputType
getType()
Get the input type from theAttributes.TYPE
attribute.@Nullable String
getValue()
Get the inputted valueboolean
Test if the element is disabled.void
setDisabled
(boolean disabled) Set theAttributes.ENABLED
attributevoid
setPlaceholder
(@Nullable String placeholder) Set the value of theAttributes.PLACEHOLDER
attribute.void
Set theAttributes.PROMPT
attribute value.void
setType
(@Nullable InputElement.InputType type) Set the input typevoid
Set the inputted value.void
Set the inputted value.Methods inherited from interface com.juliewoolie.dom.DomQueryable
getElementsByClassName, getElementsByTagName, querySelector, querySelectorAll
Methods inherited from interface com.juliewoolie.dom.Element
appendChild, appendElement, appendText, clearChildren, firstChild, forEachDescendant, getAttribute, getAttributeEntries, getAttributeNames, getChild, getChildCount, getChildren, getClassList, getClassName, getCurrentStyle, getId, getInlineStyle, getTagName, getTextContent, getTitleNode, getTooltip, hasAttribute, hasChild, hasChildren, indexOf, insertAfter, insertBefore, isDescendant, lastChild, matches, prependChild, removeAttribute, removeChild, removeChild, removeMatchingChildren, replaceChild, replaceChild, setAttribute, setClassName, setId, setTextContent, setTitleNode
Methods inherited from interface com.juliewoolie.dom.event.EventTarget
addEventListener, dispatchEvent, getOnAddAttribute, getOnAddOption, getOnAppendChild, getOnAttributeChange, getOnClick, getOnClosing, getOnInput, getOnLoaded, getOnMouseEnter, getOnMouseExit, getOnMouseMove, getOnOptionChange, getOnRemoveAttribute, getOnRemoveChild, getOnRemoveOption, getOnRightClick, getOnSetAttribute, getOnSetOption, getOnSpawned, onAddAttribute, onAddOption, onAppendChild, onAttributeChange, onClick, onClosing, onInput, onLoaded, onMouseEnter, onMouseExit, onMouseMove, onOptionChange, onRemoveAttribute, onRemoveChild, onRemoveOption, onRightClick, onSetAttribute, onSetOption, onSpawned, removeEventListener
Methods inherited from interface com.juliewoolie.dom.Node
enterVisitor, exitVisitor, getDepth, getOwningDocument, getParent, getRenderingBounds, getSiblingIndex, hasFlag, nextSibling, previousSibling
-
Field Details
-
DEFAULT_PLACEHOLDER
Default placeholder value returned bygetPlaceholder()
- See Also:
-
-
Method Details
-
canHaveChildren
@Contract("-> false") boolean canHaveChildren()Input elements cannot have child nodes.- Specified by:
canHaveChildren
in interfaceElement
- Returns:
false
-
isDisabled
boolean isDisabled()Test if the element is disabled.This element can be disabled by setting the
Attributes.ENABLED
attribute tofalse
.- Returns:
true
, if the element is disabled,false
otherwise
-
setDisabled
void setDisabled(boolean disabled) Set theAttributes.ENABLED
attribute- Parameters:
disabled
-true
to disable the element,false
otherwise.
-
getPrompt
String getPrompt()Get theAttributes.PROMPT
attribute value.The prompt is displayed to players when asking for input
- Returns:
- Prompt
-
setPrompt
Set theAttributes.PROMPT
attribute value.The prompt is displayed to players when asking for input
- Parameters:
prompt
- Prompt
-
getType
Get the input type from theAttributes.TYPE
attribute.If the attribute isn't set or its value does not map to an enum value, then
InputElement.InputType.TEXT
is returned.- Returns:
- Input type
-
setType
Set the input type- Parameters:
type
- Input type, ornull
.
-
getValue
Get the inputted value- Returns:
- Inputted value, may be an empty string or
null
-
setValue
Set the inputted value.Triggers a
EventTypes.INPUT
event.- Parameters:
value
- New element value
-
setValue
Set the inputted value.Triggers a
EventTypes.INPUT
event.- Parameters:
value
- New element valueplayer
- Player that changed the element
-
getPlaceholder
Get the element's placeholder, or a fallback value, if not set.Placeholders are set with the
Attributes.PLACEHOLDER
attribute. If the attribute is not explicitly set, then this method returnsDEFAULT_PLACEHOLDER
.- Returns:
- Placeholder
-
setPlaceholder
Set the value of theAttributes.PLACEHOLDER
attribute.- Parameters:
placeholder
- New placeholder
-