MRTextInputEntity

MRTextInputEntity ⇐ MRTextEntity

Base text inpu entity represented in 3D space. mr-text-input

Kind: global class
Extends: MRTextEntity

mrTextInputEntity.MRTextInputEntity

Kind: instance class of MRTextInputEntity

new exports.MRTextInputEntity()

Constructor for the MRTextInputEntity entity component.

mrTextInputEntity.value() ⇒ string

Gets the value of the text for the current hiddenInput DOM object

Kind: instance method of MRTextInputEntity
Returns: string - value - the text value of the current hiddenInput DOM object

mrTextInputEntity.value()

Sets the value of the text for the current hiddenInput DOM object

Kind: instance method of MRTextInputEntity

mrTextInputEntity.createHiddenInputElement()

Function to be overwritten by children. Called by connected to make sure the hiddenInput dom element is created as expected.

Kind: instance method of MRTextInputEntity

mrTextInputEntity.fillInHiddenInputElementWithUserData()

Function to be overwritten by children. Called by connected after createHiddenInputElement to fill it in with the user’s given attribute information.

Kind: instance method of MRTextInputEntity

mrTextInputEntity.updateTextDisplay(fromCursorMove)

Function to be overwritten by children. Used on event trigger to update the textObj visual based on the hiddenInput DOM element.

Kind: instance method of MRTextInputEntity

Param Type Default Description
fromCursorMove boolean false default set as false if not supplied. See MRTextArea and MRTextField as examples. This param is helpful for cases where the visible region of text can differ from the full text value. Since cursor movement already handles scrolling for that region change, then we only need to update the new text. Otherwise, we also need to scroll and update the new text.

mrTextInputEntity.connected()

(async) Handles setting up this textarea once it is connected to run as an entity component.

Kind: instance method of MRTextInputEntity

mrTextInputEntity._createCursorObject()

Internal function used to setup the cursor object and associated variables needed during runtime. Sets the cursor geometry based on dev updated cursorWidth and cursorHeight MRTextInputEntity variables.

Kind: instance method of MRTextInputEntity

mrTextInputEntity._updateCursorSize(newHeight)

Internal function used to setup the cursor object and associated variables needed during runtime. User can pass in a new height directly or the function checks whether cursor height should be updated based on fontSize compared to line height and other aspects.

Kind: instance method of MRTextInputEntity

Param Type Description
newHeight number an optional parameter to be used as the cursor’s new height.

mrTextInputEntity.handleKeydown(event)

Function to be overwritten by children. Called by the keydown event trigger.

Kind: instance method of MRTextInputEntity

Param Type Description
event event the keydown event

mrTextInputEntity.handleMouseClick(event)

Called by the mouse click event trigger. Handles determining the caret position based on the 3D textObj to hiddenInput DOM position conversion.

Kind: instance method of MRTextInputEntity

Param Type Description
event event the mouseclick event

mrTextInputEntity._focus(isPureFocusEvent)

Called by the focus event trigger and in other ‘focus’ situations. We use the private version of this function signature to not hit the intersection of the actual ‘focus()’ event naming that we have connected. See ‘setupEventListeners()’ description for more info.

Kind: instance method of MRTextInputEntity

Param Type Default Description
isPureFocusEvent boolean false Boolean to allow us to update the cursor position with this function directly. Otherwise, we assume there’s other things happening after focus was called as part of the event and that the cursor position will be handled there instead.

mrTextInputEntity._blur()

Called by the blur event trigger and in other ‘blur’ situations. We use the private version of this function signature to not hit the intersection of the actual ‘blur()’ event naming that we have connected. See ‘setupEventListeners()’ description for more info.

Kind: instance method of MRTextInputEntity

mrTextInputEntity.hasTextSubsetForVerticalScrolling() ⇒ boolean

Getter for whether this textinput should handle vertical scrolling or not.

Kind: instance method of MRTextInputEntity
Returns: boolean - true if it should be handled, false otherwise

mrTextInputEntity.hasTextSubsetForHorizontalScrolling() ⇒ boolean

Getter for whether this textinput should handle horizontal scrolling or not.

Kind: instance method of MRTextInputEntity
Returns: boolean - true if it should be handled, false otherwise

mrTextInputEntity.inputIsDisabled() ⇒ boolean

Getter for a commonly needed attribute: ‘disabled’ for whether this input is still being updated.

Kind: instance method of MRTextInputEntity
Returns: boolean - true if disabled, false otherwise

mrTextInputEntity.inputIsReadOnly() ⇒ boolean

Getter for a commonly needed attribute: ‘readonly’ for whether this input’s text can still be changed.

Kind: instance method of MRTextInputEntity
Returns: boolean - true if readonly, false otherwise

mrTextInputEntity.setupEventListeners()

Connecting the event listeners to the actual functions that handle them. Includes additional calls where necessary.

Since we want the text input children to be able to override the parent function event triggers, separating them into an actual function here and calling them manually instead of doing the pure ‘functionname () => {} event type setup’. This manual connection allows us to call super.func() for event functions; otherwise, theyre not accessible nor implemented in the subclasses.

Kind: instance method of MRTextInputEntity

mrTextInputEntity._totalLengthUpToLineIndex(lineIndex, allLines) ⇒ number

Helper function for handleKeyDown and updateCursorPosition when handling textObj.

Kind: instance method of MRTextInputEntity
Returns: number - length of summed string.

Param Type Description
lineIndex number the ending line index non-inclusive of the summation.
allLines Array the array of line strings

mrTextInputEntity._totalLengthBetweenLineIndices(lineIndexStart, lineIndexEnd, allLines) ⇒ number

Helper function for handleKeyDown and updateCursorPosition when handling textObj.

Kind: instance method of MRTextInputEntity
Returns: number - length of summed string.

Param Type Description
lineIndexStart number the starting line index inclusive of the summation.
lineIndexEnd number the starting line index non-inclusive of the summation.
allLines Array the array of line strings

mrTextInputEntity.updateCursorPosition(fromCursorMove)

Updates the cursor position based on click and selection location.

Kind: instance method of MRTextInputEntity

Param Type Default Description
fromCursorMove boolean false false by default. Used to determine if we need to run based off a text object update sync or we can directly grab information. This requirement occurs because the sync isnt usable if no text content changed. Note: this function does not change anything about the this.hiddenInput.selectionStart nor this.hiddenInput.selectionEnd. Those values should be changed prior to this function being called.