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

</div>

Class

# ToolbarButton (deprecated)

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

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2021r3. Please use `DesktopToolbarButton</api/user_interface/desktop/desktoptoolbarbutton>` as a replacement.

</div>

## Description

A button for a `Toolbar</api/deprecated/toolbar>`. Use the <span class="title-ref">ToolbarButton</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 |
|------------------------------------------|--------------------------------------|-----------|--------|
| `ButtonStyle<toolbarbutton.buttonstyle>` | `Integer</api/data_types/integer>`   |           |        |
| `Caption<toolbarbutton.caption>`         | `String</api/data_types/string>`     |           |        |
| `Enabled<toolbarbutton.enabled>`         | `Boolean</api/data_types/boolean>`   |           |        |
| `Icon<toolbarbutton.icon>`               | `Picture</api/graphics/picture>`     |           |        |
| `Menu<toolbarbutton.menu>`               | `MenuItem</api/deprecated/menuitem>` |           |        |
| `Name<toolbarbutton.name>`               | `String</api/data_types/string>`     |           |        |
| `Pressed<toolbarbutton.pressed>`         | `Boolean</api/data_types/boolean>`   |           |        |
| `Tag<toolbarbutton.tag>`                 | `Variant</api/data_types/variant>`   |           |        |
| `Tooltip<toolbarbutton.tooltip>`         | `String</api/data_types/string>`     |           |        |

## Enumerations

<div id="toolbarbutton.buttonstyles">

<div class="rst-class">

forsearch

</div>

</div>

ToolbarButton.ButtonStyles

### ButtonStyles

Specifies the type of button.

| enum             | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| PushButton       | The ToolButton is a pushbutton.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ToggleButton     | The ToolbarButton 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 "Pressed" state at one time. Pressing one changes the state of the other toggle buttons, effectively making them work similarly to RadioButtons.                                                                                                                                                                  |
| Separator        | The ToolbarButton is a separator. Not supported on macOS.                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| DropDown         | The ToolbarButton is a drop-down menu. On Windows, an arrow is drawn by default. To specify the menu, assign it to the `Menu<desktoptoolbarbutton.menu>` property of the `DesktopToolbarButton</api/user_interface/desktop/desktoptoolbarbutton>` class. Handle the selected menu item in the `MenuItemSelected<desktoptoolbar.menuitemselected>` event of the `DesktopToolbar</api/user_interface/desktop/desktoptoolbar>` class. See the example for the ToolbarButton class.                                                  |
| SeparateDropDown | The ToolbarButton 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 `Menu<desktoptoolbarbutton.menu>` property of the `DesktopToolbarButton</api/user_interface/desktop/desktoptoolbarbutton>` class. Handle the selected menu item in the `MenuItemSelected<desktoptoolbar.menuitemselected>` event of the `DesktopToolbar</api/user_interface/desktop/desktoptoolbar>` class. See the example for the DesktopToolbarButton class. |
| Space            | The ToolbarButton is a fixed-width space between ToolbarButtons. This is not supported on Windows, so no extra button or space appears.                                                                                                                                                                                                                                                                                                                                                                                          |
| FlexibleSpace    | The ToolbarButton is a variable-width space between ToolbarButtons. 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.                                                                                                                                                                                                                                                                                                           |

## Property descriptions

<div id="toolbarbutton.buttonstyle">

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

</div>

<div class="rst-class">

forsearch

</div>

ToolbarButton.ButtonStyle

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

Determines the type of button.

Get and set this property using the `ButtonStyles<toolbarbutton.buttonstyles>` enumeration.

<div id="toolbarbutton.caption">

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

</div>

<div class="rst-class">

forsearch

</div>

ToolbarButton.Caption

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

The caption of the ToolbarItem.

This property can be set inside the IDE or programmatically.

To set an accelerator character, precede the character in the Caption with an ampersand. In order to show an ampersand in the Caption, use two ampersands in a row.

This code sets the caption of the ToolBarItem to "Bold".

``` xojo
Me.Caption = "Bold"
```

<div id="toolbarbutton.enabled">

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

</div>

<div class="rst-class">

forsearch

</div>

ToolbarButton.Enabled

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

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

<div id="toolbarbutton.icon">

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

</div>

<div class="rst-class">

forsearch

</div>

ToolbarButton.Icon

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

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

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

``` xojo
DropDownButton = New ToolButton
DropDownButton.ButtonStyle = ToolbarButton.ButtonStyles.DropDown
DropDownButton.Caption = "Cities"

' create a menu
Var myMenu As New MenuItem
Var myMenuItem1 As New MenuItem
Var myMenuItem2 As New MenuItem
Var 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.Add(myMenuItem1)
myMenu.Add(myMenuItem2)
myMenu.Add(myMenuItem3)

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

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

<div id="toolbarbutton.menu">

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

</div>

<div class="rst-class">

forsearch

</div>

ToolbarButton.Menu

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

The menu that is used with a button of style DropDown or SeparateDropDown. Use the `ButtonStyle<toolbarbutton.buttonstyle>` property to set the type of button.

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

``` xojo
DropDownButton = New ToolbarButton
DropDownButton.ButtonStyle = ToolbarButton.ButtonStyles.DropDown
DropDownButton.Caption = "Cities"

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

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

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

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

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

<div id="toolbarbutton.name">

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

</div>

<div class="rst-class">

forsearch

</div>

ToolbarButton.Name

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

The name of the **ToolbarItem**.

<div id="toolbarbutton.pressed">

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

</div>

<div class="rst-class">

forsearch

</div>

ToolbarButton.Pressed

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

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

<div id="toolbarbutton.tag">

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

</div>

<div class="rst-class">

forsearch

</div>

ToolbarButton.Tag

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

A “hidden” value associated with the toolbar item.

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

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

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

<div id="toolbarbutton.tooltip">

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

</div>

<div class="rst-class">

forsearch

</div>

ToolbarButton.Tooltip

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

The tooltip that is displayed when the pointer is over the **ToolbarItem**.

## Sample code

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

``` xojo
Var dropDownButton As New ToolbarButton
dropDownButton.ButtonStyle = ToolbarButton.ButtonStyles.DropDownMenu
dropDownButton.Caption = "Cities"
dropDownButton.Name = "CitiesMenu"

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

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

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

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

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

``` xojo
Event MenuItemSelected(button As ToolbarItem, selectedItem As MenuItem)
  Select Case selectedItem.Text
  Case "Grand Blanc"
    MessageBox("You chose Grand Blanc from the " + selectedItem.Name + " .")
  Case "Flint"
    MessageBox("You chose Flint from the " + selectedItem.Name + " .")
  Case "Bad Axe"
    MessageBox("you chose Bad Axe from the " + selectedItem.Name + " .")
  End Select
End Event
```

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

This code adds a toggle style button to the toolbar. This code is in the `Open<control.open>` event of the Toolbar:

``` xojo
Var toggleButton As New ToolbarButton
toggleButton.ButtonStyle = ToolbarButton.ButtonStyles.ToggleButton
toggleButton.Caption = "Toggle"
Me.Add(toggleButton)
```

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

This code will push a toggle style button that is the first button on a toolbar (code is in the `Open<control.open>` event handler of the Toolbar):

``` xojo
ToolButton.Pressed = Not ToolbarButton.Pressed
```

## 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.
