Interface Widget


  • public interface Widget
    Represents an on-screen UI element that is drawn on the canvas.

    It should be noted that most RuneLite-added elements are not Widgets, but are an Overlay. Notable exceptions include bank tag tabs and chatbox inputs

    Examples of Widgets include:

    • The fairy ring configuration selector
    • The mini-map
    • The bank inventory

    For a more complete idea of what is classified as a widget, see WidgetID.

    • Method Detail

      • getType

        int getType()
        Gets the type of the widget.
        See Also:
        WidgetType
      • setType

        void setType​(int type)
        Sets the type of the widget.
        See Also:
        WidgetType
      • getContentType

        int getContentType()
        Gets the type of content displayed by the widget.
      • setContentType

        Widget setContentType​(int contentType)
        Sets the type of content displayed by the widget.
      • getClickMask

        int getClickMask()
        Gets the current click configuration of the widget.
        See Also:
        WidgetConfig
      • setClickMask

        Widget setClickMask​(int mask)
        Sets the click configuration of the widget.
        See Also:
        WidgetConfig
      • getParent

        Widget getParent()
        Gets the parent widget, if this widget is a child.
        Returns:
        the parent widget, or null
      • getParentId

        int getParentId()
        Gets the ID of the parent widget.
        Returns:
        the parent ID, or -1 if this widget is not a child
      • getChild

        @Nullable
        Widget getChild​(int index)
        Gets a dynamic child by index
      • getChildren

        @Nullable
        Widget[] getChildren()
        Gets the dynamic children of this widget in a sparse array
      • setChildren

        void setChildren​(Widget[] children)
        Sets the dynamic children sparse array
      • getDynamicChildren

        Widget[] getDynamicChildren()
        Gets all dynamic children.
        Returns:
        the dynamic children
      • getStaticChildren

        Widget[] getStaticChildren()
        Gets all static children.
        Returns:
        the static children
      • getNestedChildren

        Widget[] getNestedChildren()
        Gets all nested children.
        Returns:
        the nested children
      • getRelativeX

        int getRelativeX()
        Gets the relative x-axis coordinate to the widgets parent.
        Returns:
        the relative x-axis coordinate
      • setRelativeX

        @Deprecated
        void setRelativeX​(int x)
        Deprecated.
        Sets the relative x-axis coordinate to the widgets parent. You do not want to use this. Use setOriginalX(int), setXPositionMode(int) and revalidate(). Almost any interaction with this widget from a clientscript will recalculate this value.
      • getRelativeY

        int getRelativeY()
        Gets the relative y-axis coordinate to the widgets parent.
        Returns:
        the relative coordinate
      • setRelativeY

        @Deprecated
        void setRelativeY​(int y)
        Deprecated.
        Sets the relative y-axis coordinate to the widgets parent. You do not want to use this. Use setOriginalY(int), setYPositionMode(int) and revalidate(). Almost any interaction with this widget from a clientscript will recalculate this value.
      • setForcedPosition

        void setForcedPosition​(int x,
                               int y)
        Set a forced position for the widget. This position overrides the relative x/y for the widget, even if the widget is revalidated. To clear the forced position pass -1 for x/y.
        Parameters:
        x - x pos relative to the parent
        y - y pos relative to the parent
      • getText

        String getText()
        Gets the text displayed on this widget.
        Returns:
        the displayed text
      • setText

        Widget setText​(String text)
        Sets the text displayed on this widget.
        Parameters:
        text - the text to display
      • getTextColor

        int getTextColor()
        Gets the color as an RGB value.
        Returns:
        RGB24 color
        See Also:
        Color.getRGB()
      • setTextColor

        Widget setTextColor​(int textColor)
        Sets the RGB color of the displayed text or rectangle.
        Parameters:
        textColor - RGB24 color
        See Also:
        Color.getRGB()
      • getOpacity

        int getOpacity()
        Gets the transparency of the rectangle
        Returns:
        0 = fully opaque, 255 = fully transparent
      • setOpacity

        Widget setOpacity​(int transparency)
        Sets the transparency of the rectangle
        Parameters:
        transparency - 0 = fully opaque, 255 = fully transparent
      • getName

        String getName()
        Gets the name "op base" of the widget.

        The name of the widget is used in the tooltip when an action is available. For example, the widget that activates quick prayers has the name "Quick-prayers" so when hovering there is a tooltip that says "Activate Quick-prayers".

        Returns:
        the name
      • setName

        Widget setName​(String name)
        Sets the name of the widget.
        Parameters:
        name - the new name
      • getModelId

        int getModelId()
        Gets the Model/NPC/Item ID displayed in the widget.
        See Also:
        getModelType()
      • setModelId

        Widget setModelId​(int id)
        Sets the Model/NPC/Item ID displayed in the widget.
        See Also:
        WidgetModelType
      • getModelType

        int getModelType()
        Gets the model type of the widget.
        See Also:
        WidgetModelType
      • setModelType

        Widget setModelType​(int type)
        Sets the model type of the widget.
        Parameters:
        type - the new model type
        See Also:
        WidgetModelType
      • getAnimationId

        int getAnimationId()
        Gets the sequence ID used to animate the model in the widget
        See Also:
        AnimationID
      • setAnimationId

        Widget setAnimationId​(int animationId)
        Sets the sequence ID used to animate the model in the widget
        See Also:
        AnimationID
      • getRotationX

        @org.jetbrains.annotations.Range(from=0L, to=2047L) int getRotationX()
        Gets the x rotation of the model displayed in the widget. 0 = no rotation, 2047 = full rotation
      • setRotationX

        Widget setRotationX​(@org.jetbrains.annotations.Range(from=0L, to=2047L) int modelX)
        Sets the x rotation of the model displayed in the widget.
        Note: Setting this value outside of the input range defined by getRotationX() will cause a client crash.
        Parameters:
        modelX - the new model x rotation value
      • getRotationY

        @org.jetbrains.annotations.Range(from=0L, to=2047L) int getRotationY()
        Gets the y rotation of the model displayed in the widget. 0 = no rotation, 2047 = full rotation
      • setRotationY

        Widget setRotationY​(@org.jetbrains.annotations.Range(from=0L, to=2047L) int modelY)
        Sets the y rotation of the model displayed in the widget.
        Note: Setting this value outside of the input range defined by getRotationY() will cause a client crash.
        Parameters:
        modelY - the new model y rotation value
      • getRotationZ

        @org.jetbrains.annotations.Range(from=0L, to=2047L) int getRotationZ()
        Gets the z rotation of the model displayed in the widget. 0 = no rotation, 2047 = full rotation
      • setRotationZ

        Widget setRotationZ​(@org.jetbrains.annotations.Range(from=0L, to=2047L) int modelZ)
        Sets the z rotation of the model displayed in the widget.
        Note: Setting this value outside of the input range defined by getRotationZ() will cause a client crash.
        Parameters:
        modelZ - the new model z rotation value
      • getModelZoom

        int getModelZoom()
        Gets the amount zoomed in on the model displayed in the widget.
      • setModelZoom

        Widget setModelZoom​(int modelZoom)
        Sets the amount zoomed in on the model displayed in the widget.
        Parameters:
        modelZoom - the new model zoom value
      • getSpriteId

        int getSpriteId()
        Gets the sprite ID displayed in the widget.
        Returns:
        the sprite ID
        See Also:
        SpriteID
      • getSpriteTiling

        boolean getSpriteTiling()
        Gets if sprites are repeated or stretched
      • setSpriteTiling

        Widget setSpriteTiling​(boolean tiling)
        Sets if sprites are repeated or stretched
      • setSpriteId

        Widget setSpriteId​(int spriteId)
        Sets the sprite ID displayed in the widget.
        Parameters:
        spriteId - the sprite ID
        See Also:
        SpriteID
      • isHidden

        boolean isHidden()
        Checks whether this widget or any of its parents are hidden. This must be ran on the client thread
        Returns:
        true if this widget or any parent is hidden, false otherwise
      • isSelfHidden

        boolean isSelfHidden()
        Checks whether this widget is hidden, not taking into account any parent hidden states.
        Returns:
        true if this widget is hidden, false otherwise
      • setHidden

        Widget setHidden​(boolean hidden)
        Sets the self-hidden state of this widget.
        Parameters:
        hidden - new hidden state
      • getIndex

        int getIndex()
        The index of this widget in it's parent's children array
      • getCanvasLocation

        Point getCanvasLocation()
        Gets the location the widget is being drawn on the canvas.

        This method accounts for the relative coordinates and bounds of any parent widgets.

        Returns:
        the upper-left coordinate of where this widget is drawn
      • getWidth

        int getWidth()
        Gets the width of the widget.

        If this widget is storing any WidgetItems, this value is used to store the number of item slot columns.

        Returns:
        the width
      • getHeight

        int getHeight()
        Gets the height of the widget.
        Returns:
        the height
      • getBounds

        Rectangle getBounds()
        Gets the area where the widget is drawn on the canvas.
        Returns:
        the occupied area of the widget
      • getItemId

        int getItemId()
        Gets the item ID displayed by the widget.
        Returns:
        the item ID
      • setItemId

        Widget setItemId​(int itemId)
        Sets the item ID displayed by the widget.
        Parameters:
        itemId - the item ID
      • getItemQuantity

        int getItemQuantity()
        Gets the quantity of the item displayed by the widget.
        Returns:
        the item quantity
      • setItemQuantity

        Widget setItemQuantity​(int quantity)
        Sets the item quantity displayed by the widget.
        Parameters:
        quantity - the quantity of the item
      • contains

        boolean contains​(Point point)
        Checks if the passed canvas points is inside of this widget's bounds
        Parameters:
        point - the canvas point
        Returns:
        true if this widget contains the point, false otherwise
      • getScrollX

        int getScrollX()
        Gets the amount of pixels the widget is scrolled in the X axis
      • setScrollX

        Widget setScrollX​(int scrollX)
        Sets the amount of pixels the widget is scrolled in the X axis
      • getScrollY

        int getScrollY()
        Gets the amount of pixels the widget is scrolled in the Y axis
      • setScrollY

        Widget setScrollY​(int scrollY)
        sets the amount of pixels the widget is scrolled in the Y axis
      • getScrollWidth

        int getScrollWidth()
        Gets the size of the widget's viewport in the X axis
      • setScrollWidth

        Widget setScrollWidth​(int width)
        Sets the size of the widget's viewport in the X axis
      • getScrollHeight

        int getScrollHeight()
        Gets the size of the widget's viewport in the Y axis
      • setScrollHeight

        Widget setScrollHeight​(int height)
        Sets the size of the widget's viewport in the Y axis
      • getOriginalX

        int getOriginalX()
        Gets the X coordinate of this widget before being adjusted by getXPositionMode()}.
      • getOriginalY

        int getOriginalY()
        Gets the Y coordinate of this widget before being adjusted by getYPositionMode()}
      • setPos

        Widget setPos​(int x,
                      int y)
        Sets the X/Y coordinates
      • setPos

        Widget setPos​(int x,
                      int y,
                      int xMode,
                      int yMode)
      • getOriginalHeight

        int getOriginalHeight()
        Gets the height coordinate of this widget before being adjusted by getHeightMode()
      • getOriginalWidth

        int getOriginalWidth()
        Gets the width coordinate of this widget before being adjusted by getWidthMode()
      • setSize

        Widget setSize​(int width,
                       int height)
      • setSize

        Widget setSize​(int width,
                       int height,
                       int widthMode,
                       int heightMode)
      • getActions

        @Nullable
        String[] getActions()
        Gets the menu options available on the widget as a sparse array.
      • createChild

        Widget createChild​(int index,
                           int type)
        Creates a dynamic widget child
        Parameters:
        index - the index of the new widget in the children list or -1 to append to the back
        type - the WidgetType of the widget
      • createChild

        Widget createChild​(int type)
        Creates a dynamic widget child at the end of the children list
        Parameters:
        type - the WidgetType of the widget
      • deleteAllChildren

        void deleteAllChildren()
        Removes all of this widget's dynamic children
      • setAction

        void setAction​(int index,
                       String action)
        Creates a menu option on the widget
        Parameters:
        index - The index of the menu
        action - The verb to be displayed next to the widget's name in the context menu
      • setOnOpListener

        void setOnOpListener​(Object... args)
        Sets a script to be ran when the a menu action is clicked. hasListener must be true for this to take effect
        Parameters:
        args - A ScriptID, then the args for the script
      • setOnDialogAbortListener

        void setOnDialogAbortListener​(Object... args)
        Sets a script to be ran when the dialog is canceled
        Parameters:
        args - A ScriptID, then the args for the script
      • setOnKeyListener

        void setOnKeyListener​(Object... args)
        Sets a script to be ran on key input
        Parameters:
        args - A ScriptID, then the args for the script
      • setOnMouseOverListener

        void setOnMouseOverListener​(Object... args)
        Sets a script to be ran when the mouse enters the widget bounds
        Parameters:
        args - A ScriptID, then the args for the script
      • setOnMouseRepeatListener

        void setOnMouseRepeatListener​(Object... args)
        Sets a script to be ran every client tick when the mouse is in the widget bounds
        Parameters:
        args - A ScriptID, then the args for the script
      • setOnMouseLeaveListener

        void setOnMouseLeaveListener​(Object... args)
        Sets a script to be ran when the mouse leaves the widget bounds
        Parameters:
        args - A ScriptID, then the args for the script
      • setOnTimerListener

        void setOnTimerListener​(Object... args)
        Sets a script to be ran every client tick
        Parameters:
        args - A ScriptID, then the args for the script
      • setOnTargetEnterListener

        void setOnTargetEnterListener​(Object... args)
        Sets a script to be ran when the target mode has been activated for this widget
        Parameters:
        args - A ScriptID, then the args for the script
      • setOnTargetLeaveListener

        void setOnTargetLeaveListener​(Object... args)
        Sets a script to be ran when the target mode has been deactivated for this widget
        Parameters:
        args - A ScriptID, then the args for the script
      • hasListener

        boolean hasListener()
        If this widget has any listeners on it
      • setHasListener

        Widget setHasListener​(boolean hasListener)
        Sets if the widget has any listeners. This should be called whenever a setXListener function is called
      • isIf3

        boolean isIf3()
        This is true if the widget is from an if3 interface, or is dynamically created
      • revalidate

        void revalidate()
        Recomputes this widget's x/y/w/h, excluding scroll
      • revalidateScroll

        void revalidateScroll()
        Recomputes this widget's group's x/y/w/h including scroll
      • getOnOpListener

        Object[] getOnOpListener()
        Gets the script and arguments to be ran when a menu action is clicked.
        Returns:
      • getOnKeyListener

        Object[] getOnKeyListener()
        Gets the script and arguments to be ran when a key is pressed.
        Returns:
      • getOnLoadListener

        Object[] getOnLoadListener()
        Gets the script and arguments to be ran when a interface is loaded.
        Returns:
      • getOnInvTransmitListener

        Object[] getOnInvTransmitListener()
        Gets the script and arguments to be ran when one of the listened for inventories changes.
        Returns:
      • getFontId

        int getFontId()
        Returns the archive id of the font used
        See Also:
        FontID
      • setFontId

        Widget setFontId​(int id)
        Sets the archive id of the font
        See Also:
        FontID
      • getBorderType

        int getBorderType()
        Returns the border type of item/sprite on the widget 0 - No border 1 - 1px black border 2 - 1px black under 1px white border (selected item)
      • setBorderType

        void setBorderType​(int thickness)
        See Also:
        getBorderType()
      • getTextShadowed

        boolean getTextShadowed()
        Returns if text is shadowed
      • setTextShadowed

        Widget setTextShadowed​(boolean shadowed)
        Sets if text should be shadowed
      • getDragDeadZone

        int getDragDeadZone()
        Returns the widget drag dead zone
      • setDragDeadZone

        void setDragDeadZone​(int deadZone)
        Sets the widget drag dead zone
      • getDragDeadTime

        int getDragDeadTime()
        Returns the widget drag dead time
      • setDragDeadTime

        void setDragDeadTime​(int deadTime)
        Sets the widget drag dead time
      • getItemQuantityMode

        int getItemQuantityMode()
        Returns widget ItemQuantityMode.
      • getXPositionMode

        int getXPositionMode()
        Gets the mode that the X position is calculated from the original X position
        See Also:
        WidgetPositionMode
      • setXPositionMode

        Widget setXPositionMode​(int xpm)
        Sets the mode that the X position is calculated from the original X position. revalidate() must be called for new values to take effect.
        See Also:
        WidgetPositionMode
      • getYPositionMode

        int getYPositionMode()
        Gets the mode that the Y position is calculated from the original Y position
        See Also:
        WidgetPositionMode
      • setYPositionMode

        Widget setYPositionMode​(int ypm)
        Sets the mode that the Y position is calculated from the original Y position. revalidate() must be called for new values to take effect.
        See Also:
        WidgetPositionMode
      • getLineHeight

        int getLineHeight()
        Get the line height for this widget.
        Returns:
      • setLineHeight

        Widget setLineHeight​(int lineHeight)
        Set the line height for this widget. If set to 0, the line height is taken from the font instead.
        Parameters:
        lineHeight -
      • getXTextAlignment

        int getXTextAlignment()
        Gets the X axis text position mode
        See Also:
        WidgetTextAlignment
      • getYTextAlignment

        int getYTextAlignment()
        Gets the Y axis text position mode
        See Also:
        WidgetTextAlignment
      • getWidthMode

        int getWidthMode()
        Gets the mode controlling widget width
        See Also:
        WidgetSizeMode
      • setWidthMode

        Widget setWidthMode​(int widthMode)
        Sets the mode controlling widget width. revalidate() must be called for new values to take effect.
        See Also:
        WidgetSizeMode
      • getHeightMode

        int getHeightMode()
        Gets the mode controlling widget width
        See Also:
        WidgetSizeMode
      • setHeightMode

        Widget setHeightMode​(int heightMode)
        Sets the mode controlling widget width. revalidate() must be called for new values to take effect.
        See Also:
        WidgetSizeMode
      • getFont

        FontTypeFace getFont()
        Gets the font that this widget uses
      • isFilled

        boolean isFilled()
        Gets if the rectangle is filled or just stroked
      • setFilled

        Widget setFilled​(boolean filled)
        Sets if the rectangle is filled or just stroked
      • getTargetVerb

        String getTargetVerb()
        Verb for spell targets
      • setTargetVerb

        void setTargetVerb​(String targetVerb)
        Verb for spell targets
      • getNoClickThrough

        boolean getNoClickThrough()
        Can widgets under this widgets be clicked in this widgets bounding box
      • setNoClickThrough

        void setNoClickThrough​(boolean noClickThrough)
        Can widgets under this widgets be clicked in this widgets bounding box
      • getNoScrollThrough

        boolean getNoScrollThrough()
        Can widgets under this widgets be scrolled in this widgets bounding box
      • setNoScrollThrough

        void setNoScrollThrough​(boolean noScrollThrough)
        Can widgets under this widgets be scrolled in this widgets bounding box
      • setVarTransmitTrigger

        void setVarTransmitTrigger​(int... trigger)
        VarPlayers that triggers this widgets varTransmitListener
      • setOnClickListener

        void setOnClickListener​(Object... args)
        Sets a script to be ran the first client tick the mouse is held ontop of this widget
        Parameters:
        args - A ScriptID, then the args for the script
      • setOnHoldListener

        void setOnHoldListener​(Object... args)
        Sets a script to be ran the every client tick the mouse is held ontop of this widget, except the first client tick.
        Parameters:
        args - A ScriptID, then the args for the script
      • setOnReleaseListener

        void setOnReleaseListener​(Object... args)
        Sets a script to be ran the first client tick the mouse is not held ontop of this widget
        Parameters:
        args - A ScriptID, then the args for the script
      • setOnDragCompleteListener

        void setOnDragCompleteListener​(Object... args)
        Sets a script to be ran when a drag operation is finished on this widget
        Parameters:
        args - A ScriptID, then the args for the script
      • setOnDragListener

        void setOnDragListener​(Object... args)
        Sets a script to be ran when this widget moves due to a drag
        Parameters:
        args - A ScriptID, then the args for the script
      • setOnScrollWheelListener

        void setOnScrollWheelListener​(Object... args)
        Sets a script to be ran when the mouse is scrolled when on the widget
        Parameters:
        args - A ScriptID, then the args for the script
      • getDragParent

        Widget getDragParent()
        Container this can be dragged in
      • setDragParent

        Widget setDragParent​(Widget dragParent)
        Container this can be dragged in
      • getOnVarTransmitListener

        Object[] getOnVarTransmitListener()
        Gets the script and arguments to be ran when one of the listened for vars changes.
        Returns:
      • setOnVarTransmitListener

        void setOnVarTransmitListener​(Object... args)
        Sets a script to be ran when a varplayer changes
        Parameters:
        args - A ScriptID, then the args for the script