<div class="meta" robots="noindex">

</div>

Class

# ToolButton (deprecated)

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2019r2. Please use `ToolbarButton</api/deprecated/toolbarbutton>` as a replacement.

</div>

## Description

A button for a `Toolbar</api/deprecated/toolbar>`. Use the <span class="title-ref">ToolButton</span> class to create the items in cross-platform toolbars.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                    | Type                                 | Read-Only | Shared |
|-----------------------------------------|--------------------------------------|-----------|--------|
| `Caption<toolbutton.caption>`           | `String</api/data_types/string>`     |           |        |
| `DropDownMenu<toolbutton.dropdownmenu>` | `MenuItem</api/deprecated/menuitem>` |           |        |
| `Enabled<toolbutton.enabled>`           | `Boolean</api/data_types/boolean>`   |           |        |
| `HelpTag<toolbutton.helptag>`           | `String</api/data_types/string>`     |           |        |
| `Icon<toolbutton.icon>`                 | `Picture</api/graphics/picture>`     |           |        |
| `Name<toolbutton.name>`                 | `String</api/data_types/string>`     |           |        |
| `Pushed<toolbutton.pushed>`             | `Boolean</api/data_types/boolean>`   |           |        |
| `Style<toolbutton.style>`               | `Integer</api/data_types/integer>`   |           |        |
| `Tag<toolbutton.tag>`                   | `Variant</api/data_types/variant>`   |           |        |

## Constants

The following class constants can be used to specify the style of the **ToolButton**.

| Class Constants           | Description                                                                                                                                                                                                                                                                                                                                                                                 |
|---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ToolStylePushButton       | The **ToolButton** is a push button. Clicking the button calls the Action event of the toolbar.                                                                                                                                                                                                                                                                                             |
| ToolStyleToggleButton     | The **ToolButton** toggles when pushed. Clicking the button calls the Action event of the toolbar.                                                                                                                                                                                                                                                                                          |
| ToolStyleSeparator        | The **ToolButton** is a separator. (Supported on Windows and Linux only.)                                                                                                                                                                                                                                                                                                                   |
| ToolStyleDropDown         | The **ToolButton** displays a drop-down menu when clicked. On Windows, the button displays with a drop-down indicator and clicking anywhere on the button displays the drop-down menu. On Linux this style works the same as ToolStyleSeparateDropDown. A drop-down indicator does not appear on macOS. The DropDownMenuAction event on the toolbar is called when a menu item is selected. |
| ToolStyleSeparateDropDown | The **ToolButton** displays a separate drop-down indicator in the button. Clicking this indicator displays the drop-down menu. Clicking the main button area calls the Action event for the toolbar. The DropDownMenuAction event on the toolbar is called when a menu item is selected. On macOS this style works the same as ToolStyleDropDown.                                           |
| ToolStyleSpace            | The **ToolButton** is a fixed-width space. (Supported on macOS and Linux only.)                                                                                                                                                                                                                                                                                                             |
| ToolStyleFlexibleSpace    | The **ToolButton** is a flexible space. (Supported on macOS and Linux only.)                                                                                                                                                                                                                                                                                                                |

## Property descriptions

<div id="toolbutton.caption">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ToolButton.Caption

**Caption** As `String</api/data_types/string>`

<div id="toolbutton.dropdownmenu">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ToolButton.DropDownMenu

**DropDownMenu** As `MenuItem</api/deprecated/menuitem>`

The drop-down menu that is used with a button of style DropDown or SeparateDropDown. Use the Style property to set the type of button.

This example is in the <span class="title-ref">ToolButton</span> example discussed on the page for this class. This code is in the Open event of the <span class="title-ref">ToolButton</span>. It builds the menu, attaches it to a DropDownButton, and appends it to the toolbar.

``` xojo
DropDownButton = New ToolButton
DropDownButton.Style = ToolButton.ToolStyleDropDown
DropDownButton.Caption = "Cities"

' create a menu
Dim myMenu As New MenuItem
Dim myMenuItem1 As New MenuItem
Dim myMenuItem2 As New MenuItem
Dim myMenuitem3 As New MenuItem

DropDownButton.Name = "Cities Menu"
myMenu.Text = "Cities"

myMenuItem1.Text = "Grand Blanc"
myMenuItem2.Text = "Bad Axe"
myMenuitem3.Text = "Flint"
myMenu.Append(myMenuItem1)
myMenu.Append(myMenuItem2)
myMenu.Append(myMenuItem3)

' assign the new menu to the toolitem..
DropDownButton.DropdownMenu = myMenu

' add to the toolbar
Me.Append(DropDownButton)
```

<div id="toolbutton.enabled">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ToolButton.Enabled

**Enabled** As `Boolean</api/data_types/boolean>`

`True</api/language/true>` if the **ToolItem** is enabled.

<div id="toolbutton.helptag">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ToolButton.HelpTag

**HelpTag** As `String</api/data_types/string>`

The help tip that is displayed when the pointer is over the **ToolItem**.

<div id="toolbutton.icon">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ToolButton.Icon

**Icon** As `Picture</api/graphics/picture>`

The picture to be displayed by the <span class="title-ref">ToolButton</span>.

This example adds icons to the Cities menu and each MenuItem in the Open event of the Toolbar.

``` xojo
DropDownButton = New ToolButton
DropDownButton.Style = ToolButton.ToolStyleDropDown
DropDownButton.Caption = "Cities"

' create a menu
Dim myMenu As New MenuItem
Dim myMenuItem1 As New MenuItem
Dim myMenuItem2 As New MenuItem
Dim myMenuitem3 As New MenuItem

DropDownButton.Name = "Cities Menu"
myMenu.Text = "Cities"
myMenu.Icon = IndiaImage

myMenuItem1.Text = "Grand Blanc"
myMenuItem2.Text = "Bad Axe"
myMenuitem3.Text = "Flint"
' icons added to the project
myMenuItem1.Icon = SaturnImage
myMenuItem2.icon = VenusImage
myMenuItem3.icon = UranusImage
myMenu.Append(myMenuItem1)
myMenu.Append(myMenuItem2)
myMenu.Append(myMenuItem3)

' assign the new menu to the toolitem..
DropDownButton.DropdownMenu = myMenu

' add to the toolbar
Me.Append(DropDownButton)
```

<div id="toolbutton.name">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ToolButton.Name

**Name** As `String</api/data_types/string>`

The name of the **ToolItem**.

<div id="toolbutton.pushed">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ToolButton.Pushed

**Pushed** As `Boolean</api/data_types/boolean>`

True if the <span class="title-ref">ToolButton</span> was pushed. It can be used to set the toggled state of a toggle-style <span class="title-ref">ToolButton</span> at runtime.

<div id="toolbutton.style">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ToolButton.Style

**Style** As `Integer</api/data_types/integer>`

Determines the type of button.

Use the following class constants:

| Class Constant            | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|---------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ToolStylePushButton       | The <span class="title-ref">ToolButton</span> is a pushbutton.                                                                                                                                                                                                                                                                                                                                                                                                     |
| ToolStyleToggleButton     | The <span class="title-ref">ToolButton</span> is a button that toggles between its normal and depressed state. It does not affect the state of any other Toggle buttons in the Toolbar. On macOS, only a single ToggleButton may be in the "Pushed" state at one time. Pushing one changes the state of the other toggle buttons, effectively making them work similarly to RadioButtons.                                                                          |
| ToolStyleSeparator        | The <span class="title-ref">ToolButton</span> is a separator. Not supported on macOS.                                                                                                                                                                                                                                                                                                                                                                              |
| ToolStyleDropDown         | The <span class="title-ref">ToolButton</span> is a drop-down menu. On Windows, an arrow is drawn by default. To specify the menu, assign it to the DropDownMenu property of the <span class="title-ref">ToolButton</span> class. Handle the selected menu item in the DropDownMenuAction event of the `Toolbar</api/deprecated/toolbar>` class. See the example for the <span class="title-ref">ToolButton</span> class.                                           |
| ToolStyleSeparateDropDown | The <span class="title-ref">ToolButton</span> is a drop-down menu with a separate down arrow on its right. There is room for the caption and the icon. To specify the menu, assign it to the DropDownMenu property of the <span class="title-ref">ToolButton</span> class. Handle the selected menu item in the DropDownMenuAction event of the `Toolbar</api/deprecated/toolbar>` class. See the example for the <span class="title-ref">ToolButton</span> class. |
| ToolStyleSpace            | The <span class="title-ref">ToolButton</span> is a fixed-width space between ToolButtons. **This is not supported on Windows**, so no extra button or space appears.                                                                                                                                                                                                                                                                                               |
| ToolStyleFlexibleSpace    | The <span class="title-ref">ToolButton</span> is a variable-width space between ToolButtons. It right-aligns the buttons to its right as the window is resized. **This is not supported on Windows**, so no extra space or button will be inserted.                                                                                                                                                                                                                |

<div id="toolbutton.tag">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ToolButton.Tag

**Tag** As `Variant</api/data_types/variant>`

A “hidden” value associated with the tool item.

The tag is accessible via code when the user chooses the tool item but, unlike the Caption property, is not displayed in the toolbar.

This example is in the Toolbar Open event of the main window.

``` xojo
Me.SaveButton.Tag = folderItemToSave
```

## Sample code

This code creates a <span class="title-ref">ToolButton</span> of style Drop-down and adds it to the toolbar. The window has a property DropDownButton as <span class="title-ref">ToolButton</span>. The Open event of the Toolbar in the window has the following code:

``` xojo
Dim dropDownButton As New ToolButton
dropDownButton.Style = ToolButton.ToolStyleDropDown
dropDownButton.Caption = "Cities"
dropDownButton.Name = "CitiesMenu"

' Create a menu
Dim myMenu As New MenuItem
myMenu.Append(New MenuItem("Grand Blanc"))
myMenu.Append(New MenuItem("Bad Axe"))
myMenu.Append(New MenuItem("Flint"))

' Assign the new menu to the toolitem..
dropDownButton.DropDownMenu = myMenu

' Add to the toolbar
Me.Append(dropDownButton)
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The following code in the `Toolbar's</api/deprecated/toolbar>` DropDownMenuAction event handles the menu selection.

``` xojo
Event DropDownMenuAction(item As ToolItem, hitItem As MenuItem)
  Select Case hitItem.Text
  Case "Grand Blanc"
    MsgBox("You chose Grand Blanc from the " + item.Name + " .")
  Case "Flint"
    MsgBox("You chose Flint from the " + item.Name + " .")
  Case "Bad Axe"
    MsgBox("you chose Bad Axe from the " + item.Name + " .")
  End Select
End Event
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This code adds a toggle style button to the toolbar. This code is in the Open event of the Toolbar:

``` xojo
Dim toggleButton As New ToolButton
toggleButton.Style = ToolButton.ToolStyleToggleButton
toggleButton.Caption = "Toggle"
Me.Append(toggleButton)
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This code will push a toggle style button that is the first button on a toolbar (code is in the Open event handler of the Toolbar):

``` xojo
ToolButton.Pushed = Not ToolButton.Pushed
```

## Compatibility

All project types on all supported operating systems.

## See also

`ToolbarItem</api/deprecated/toolbaritem>` parent class; `Toolbar</api/deprecated/toolbar>`, `ToolbarItem</api/deprecated/toolbaritem>` classes.
