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

      • getId

        int getId()
        Gets the widgets ID.
        See Also:
        WidgetID
      • 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

        void 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, WidgetConfig
      • setClickMask

        void 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
      • getChildren

        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.
      • getText

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

        void 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

        void 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

        void 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

        void 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:
        WidgetModelType
      • setModelId

        void 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

        void 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

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

        int getRotationX()
        Gets the x rotation of the model displayed in the widget. 0 = no rotation, 2047 = full rotation
      • setRotationX

        void setRotationX​(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

        int getRotationY()
        Gets the y rotation of the model displayed in the widget. 0 = no rotation, 2047 = full rotation
      • setRotationY

        void setRotationY​(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

        int getRotationZ()
        Gets the z rotation of the model displayed in the widget. 0 = no rotation, 2047 = full rotation
      • setRotationZ

        void setRotationZ​(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

        void 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

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

        void 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

        void 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
      • getWidgetItems

        Collection<WidgetItem> getWidgetItems()
        Gets any items that are being displayed in the widget.
        Returns:
        any items displayed, or null if there are no items
      • getWidgetItem

        WidgetItem getWidgetItem​(int index)
        Gets a widget item at a specific index.
        Parameters:
        index - index of the item
        Returns:
        the widget item at index, or null if an item at index does not exist
        Throws:
        IndexOutOfBoundsException - if the index is out of bounds
      • getItemId

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

        void 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

        void 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

        void 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

        void 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

        void 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

        void 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()}
      • 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()
      • getActions

        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 type 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

        void 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

        void 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

        void 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.
      • setItemQuantityMode

        void setItemQuantityMode​(int itemQuantityMode)
        Sets the widget ItemQuantityMode
      • getXPositionMode

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

        void 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

        void 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
      • getXTextAlignment

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

        void setXTextAlignment​(int xta)
        Sets the X axis text position mode
        See Also:
        WidgetTextAlignment
      • getYTextAlignment

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

        void setYTextAlignment​(int yta)
        Sets the Y axis text position mode
        See Also:
        WidgetTextAlignment
      • getWidthMode

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

        void 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

        void 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

        void 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
      • getDragParent

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

        void setDragParent​(Widget dragParent)
        Container this can be dragged in
      • 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