JavaScript is disabled on your browser.
Skip navigation links
org.htmlunit.javascript.host.dom

Class Selection

    • Field Summary

      • Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject

        CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
      • Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable

        NOT_FOUND
    • Constructor Summary

      Constructors
      Constructor and Description
      Selection ()
    • Method Summary

      All Methods
      Modifier and Type Method and Description
      void addRange (Range range)
      Adds a range to the selection.
      void collapse (Node parentNode, int offset)
      Collapses the current selection to a single point.
      void collapseToEnd ()
      Moves the anchor of the selection to the same point as the focus.
      void collapseToStart ()
      Moves the focus of the selection to the same point at the anchor.
      void empty ()
      Cancels the current selection, sets the selection type to none.
      void extend (Node parentNode, int offset)
      Moves the focus of the selection to a specified point.
      Node getAnchorNode ()
      Returns the node in which the selection begins.
      int getAnchorOffset ()
      Returns the number of characters that the selection's anchor is offset within the anchor node.
      Object getDefaultValue (Class<?> hint)
      Returns the JavaScript default value of this object.
      Node getFocusNode ()
      Returns the node in which the selection ends.
      int getFocusOffset ()
      Returns the number of characters that the selection's focus is offset within the focus node.
      Range getRangeAt (int index)
      Returns the range at the specified index.
      int getRangeCount ()
      Returns the number of ranges in the selection.
      String getType ()
      Returns the type of selection (IE only).
      boolean isIsCollapsed ()
      Returns a boolean indicating whether the selection's start and end points are at the same position.
      void jsConstructor ()
      JavaScript constructor.
      String jsToString ()
      void removeAllRanges ()
      Removes all ranges from the selection.
      void removeRange (Range range)
      Removes a range from the selection.
      void selectAllChildren (Node parentNode)
      Adds all the children of the specified node to the selection.
      • Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject

        applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChangeForSlot, checkPropertyDefinition, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, ensureType, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size
      • Methods inherited from class org.htmlunit.corejs.javascript.SlotMapOwner

        createSlotMap
    • Constructor Detail

      • Selection

        public Selection()
    • Method Detail

      • jsConstructor

        public void jsConstructor()
        JavaScript constructor.
      • jsToString

        public String jsToString()
        Returns:
        a string currently being represented by the selection object, i.e. the currently selected text.
      • getDefaultValue

        public Object getDefaultValue(Class<?> hint)
        Returns the JavaScript default value of this object. This is the JavaScript equivalent of a toString() in Java.
        Specified by:
        getDefaultValue in interface org.htmlunit.corejs.javascript.Scriptable
        Overrides:
        getDefaultValue in class HtmlUnitScriptable
        Parameters:
        hint - a hint as to the format of the default value (ignored in this case)
        Returns:
        the default value
      • getAnchorNode

        public Node getAnchorNode()
        Returns the node in which the selection begins.
        Returns:
        the node in which the selection begins
      • getAnchorOffset

        public int getAnchorOffset()
        Returns the number of characters that the selection's anchor is offset within the anchor node.
        Returns:
        the number of characters that the selection's anchor is offset within the anchor node
      • getFocusNode

        public Node getFocusNode()
        Returns the node in which the selection ends.
        Returns:
        the node in which the selection ends
      • getFocusOffset

        public int getFocusOffset()
        Returns the number of characters that the selection's focus is offset within the focus node.
        Returns:
        the number of characters that the selection's focus is offset within the focus node
      • isIsCollapsed

        public boolean isIsCollapsed()
        Returns a boolean indicating whether the selection's start and end points are at the same position.
        Returns:
        a boolean indicating whether the selection's start and end points are at the same position
      • getRangeCount

        public int getRangeCount()
        Returns the number of ranges in the selection.
        Returns:
        the number of ranges in the selection
      • getType

        public String getType()
        Returns the type of selection (IE only).
        Returns:
        the type of selection
      • addRange

        public void addRange(Range range)
        Adds a range to the selection.
        Parameters:
        range - the range to add
      • removeRange

        public void removeRange(Range range)
        Removes a range from the selection.
        Parameters:
        range - the range to remove
      • removeAllRanges

        public void removeAllRanges()
        Removes all ranges from the selection.
      • getRangeAt

        public Range getRangeAt(int index)
        Returns the range at the specified index.
        Parameters:
        index - the index of the range to return
        Returns:
        the range at the specified index
      • collapse

        public void collapse(Node parentNode,
         int offset)
        Collapses the current selection to a single point. The document is not modified.
        Parameters:
        parentNode - the caret location will be within this node
        offset - the caret will be placed this number of characters from the beginning of the parentNode's text
      • collapseToEnd

        public void collapseToEnd()
        Moves the anchor of the selection to the same point as the focus. The focus does not move.
      • collapseToStart

        public void collapseToStart()
        Moves the focus of the selection to the same point at the anchor. The anchor does not move.
      • empty

        public void empty()
        Cancels the current selection, sets the selection type to none.
      • extend

        public void extend(Node parentNode,
         int offset)
        Moves the focus of the selection to a specified point. The anchor of the selection does not move.
        Parameters:
        parentNode - the node within which the focus will be moved
        offset - the number of characters from the beginning of parentNode's text the focus will be placed
      • selectAllChildren

        public void selectAllChildren(Node parentNode)
        Adds all the children of the specified node to the selection. The previous selection is lost.
        Parameters:
        parentNode - all children of parentNode will be selected; parentNode itself is not part of the selection
Skip navigation links

Copyright © 2002–2025 Gargoyle Software Inc.. All rights reserved.

AltStyle によって変換されたページ (->オリジナル) /