# RSInterface Controls This page is about controls on runescape interfaces. These can be buttons, scrollbars, dropdowns, checkboxes, etc. - - - ## TRSButton RuneScape has several types of buttons, {ref}`TRSButton` can be used for several of them but it's made specifically for buttons that have an "enabled" and "disabled" state: ```{figure} ../../images/trsbuttons.png ``` You can also use them very effectively for this type of buttons that are "linked" together: ```{figure} ../../images/linked_trsbuttons.png ``` With "linked", it means that enabling one, disabled the linked one(s). You can also use them for other types of buttons and imagination is the limit but in a lot of cases you won't be able to make use of the {ref}`TRSButton` methods. - - - ### TRSButton.Enabled ```pascal function TRSButton.Enabled(): Boolean; ``` Returns True/False if the button is enabled. Example: ```pascal WriteLn Button.Enabled(); ``` - - - ### TRSButton.WaitEnabled ```pascal function TRSButton.WaitEnabled(time: Integer = 600; interval: Integer = -1): Boolean; ``` Returns True if the button is enabled within `time` milliseconds. Example: ```pascal WriteLn Button.WaitEnabled(); ``` - - - ### TRSButton.Click ```pascal procedure TRSButton.Click(button: EMouseButton = EMouseButton.LEFT); ``` Clicks a {ref]`TRSButton` with the specified mouse `button` which by default is the left one. Example: ```pascal Button.Click(); ``` - - - ### TRSButton.Enable ```pascal function TRSButton.Enable(): Boolean; ``` Attempts to enable a {ref]`TRSButton`. This is done with the left mouse click and the function returns true if {ref}`TRSButton.Enabled` returns true. Example: ```pascal WriteLn Button.Enable(); ``` - - - ### TRSButton.Disable ```pascal function TRSButton.Disable(): Boolean; ``` Attempts to disable a {ref]`TRSButton`. This is done with the left mouse click and the function returns true if {ref}`TRSButton.Enabled` returns false. Example: ```pascal WriteLn Button.Disable(); ``` - - - ## TRSSlider A record meant to handle sliders in the game interfaces: ```{figure} ../../images/sliders.png ``` - - - ### TRSSlider.GetLevel ```pascal function TRSSlider.GetLevel(): Integer; ``` Returns the slider level from 0 to 100. It's important to keep in mind that while we use a scale from 0 to 100, don't have that many "levels". For example, the brightness slider only have 5 or 6 possible positions. Example: ```pascal WriteLn slider.GetLevel(); ``` - - - ### TRSSlider.SetLevel ```pascal function TRSSlider.SetLevel(level: Integer): Boolean; ``` Attempts to set the slider to the specified `level`. Example: ```pascal WriteLn slider.SetLevel(60); ``` - - - ## TRSScrollBar Record to handle the game interface's scrollbars: ```{figure} ../../images/scrollbar.png ``` - - - ### TRSScrollBar.Setup ```pascal procedure TRSScrollBar.Setup(); ``` Method used to setup several {ref}`TRSScrollBar` internal variables. When creating a {ref}`TRSScrollBar` you should first setup it's `Area` variable and then call this. Example: ```pascal scroll.Area.X1 := Bank.Bounds.X1 + 5; scroll.Area.Y1 := Bank.Bounds.Y1 + 78; scroll.Area.X2 := Bank.Bounds.X2 - 22; scroll.Area.Y2 := Bank.Bounds.Y2 - 44; scroll.Setup(); ``` - - - ### TRSScrollBar.IsVisible ```pascal function TRSScrollBar.IsVisible(): Boolean; ``` Returns True/False if the scrollbar is visible. Example: ```pascal WriteLn Bank.Scroll.IsVisible(); ``` - - - ### TRSScrollBar.Slider ```pascal property TRSScrollBar.Slider: TBox; ``` Returns a `TBox` of the scrollbar slider. Example: ```pascal ShowOnTarget(Bank.Scroll.GetSlider()); ``` ```{figure} ../../images/scrollbar_slider.png ``` - - - ### TRSScrollBar.CanScroll ```pascal function TRSScrollBar.CanScroll(): Boolean; ``` Returns True/False if the scrollbar is "scrollable". A scrollbar is not scrollable if it's not visible or if the slider occupies the whole space available. Example: ```pascal WriteLn Chat.Scroll.CanScroll(); ``` - - - ### TRSScrollBar.GetLevel ```pascal function TRSScrollBar.GetLevel(): Integer; ``` Returns the level of the scrollbar. This is a percentage between the available space and the slider size. Example: ```pascal WriteLn Chat.Scroll.GetLevel(); ``` - - - ### TRSScrollBar.ScrollArea ```pascal property TRSScrollBar.ScrollArea: TBox; ``` Returns a area where you can scroll the mouse, using {ref}`TBiometrics` between `TRSScrollBar.Area` and `TRSScrollBar.Bounds`. Example: ```pascal ShowOnTarget(Chat.Scroll.GetScrollArea()); ``` - - - ### TRSScrollBar.SetLevel ```pascal function TRSScrollBar.SetLevel(value: Integer): Integer; ``` Attempts to set a scroll level on a scrollbar. Example: ```pascal WriteLn Chat.Scroll.SetLevel(50); ``` - - - ### TRSScrollBar.Scroll ```pascal function TRSScrollBar.Scroll(amount: Integer; down: Boolean): Boolean; ``` Scroll `amount` amount of times in a direction decided by `down`. Example: ```pascal WriteLn Chat.Scroll.Scroll(3, True); ``` - - - ## TRSDropDownOption Helper record to handle {ref}`TRSDropDown` options. - - - ## TRSDropDown Record to handle drop downs in the game interfaces: ```{figure} ../../images/dropdowns.png ``` - - - ### TRSDropDown.Setup ```pascal procedure TRSDropDown.Setup(options: TStringArray); ``` Sets up a {ref}`TRSDropDown` internal variables. This has to be used after the `TRSDropDown.Bounds` variable is already set. Example: ```pascal DropDown.Setup(['Fixed - Classic layout', 'Resizable - Classic layout', 'Resizable - Modern layout']); ``` - - - ### TRSDropDown.IsVisible ```pascal function TRSDropDown.IsVisible(): Boolean; ``` Returns true if a {ref}`TRSDropDown` is visible. Example: ```pascal WriteLn Options.DropDowns[ERSOptionsDropDown.CLIENT_MODE].IsVisible(); ``` - - - ### TRSDropDown.IsOpen ```pascal function TRSDropDown.IsOpen(): Boolean; ``` Returns true if a {ref}`TRSDropDown` is open. Example: ```pascal WriteLn Options.DropDowns[ERSOptionsDropDown.CLIENT_MODE].IsOpen(); ``` - - - ### TRSDropDown.WaitOpen ```pascal function TRSDropDown.WaitOpen(time: Integer = 600; interval: Integer = -1): Boolean; ``` Returns true if {ref}`TRSDropDown.IsOpen` returns true within `time` milliseconds. Example: ```pascal WriteLn Options.DropDowns[ERSOptionsDropDown.CLIENT_MODE].WaitOpen(); ``` - - - ### TRSDropDown.Open ```pascal function TRSDropDown.Open(): Boolean; ``` Attempts to open a {ref}`TRSDropDown`. Example: ```pascal WriteLn Options.DropDowns[ERSOptionsDropDown.CLIENT_MODE].Open(); ``` - - - ### TRSDropDown.Close ```pascal function TRSDropDown.Close(): Boolean; ``` Attempts to close a {ref}`TRSDropDown`. Example: ```pascal WriteLn Options.DropDowns[ERSOptionsDropDown.CLIENT_MODE].Close(); ``` - - - ### TRSDropDown.GetSelected ```pascal function TRSDropDown.GetSelected(): Integer; ``` Returns the index of the currently selected option on a {ref}`TRSDropDown`. Example: ```pascal WriteLn Options.DropDowns[ERSOptionsDropDown.CLIENT_MODE].GetSelected(); ``` - - - ### TRSDropDown.Select ```pascal function TRSDropDown.Select(index: Integer): Boolean; function TRSDropDown.Select(option: String): Boolean; overload; ``` Attempts to select an option on a {ref}`TRSDropDown`. You can either use an option index or substring of an option. If you use a substring, the first match will be used. Example: ```pascal WriteLn Options.DropDowns[ERSOptionsDropDown.CLIENT_MODE].Select('Fixed'); ```