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

</div>

Class

# Toolbar (deprecated)

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

<div class="warning">

<div class="title">

Warning

</div>

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

</div>

## Description

Used to create a <span class="title-ref">Toolbar</span> in a window. The <span class="title-ref">Toolbar</span> control is supported on all desktop platforms.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                               | Type                               | Read-Only | Shared |
|----------------------------------------------------|------------------------------------|-----------|--------|
| `AllowAutoDeactivate<toolbar.allowautodeactivate>` | `Boolean</api/data_types/boolean>` |           |        |
| `AllowTabStop<toolbar.allowtabstop>`               | `Boolean</api/data_types/boolean>` |           |        |
| `Enabled<toolbar.enabled>`                         | `Boolean</api/data_types/boolean>` |           |        |
| `Handle<toolbar.handle>`                           | `Integer</api/data_types/integer>` | ✓         |        |
| `Height<toolbar.height>`                           | `Integer</api/data_types/integer>` |           |        |
| `Name<toolbar.name>`                               | `String</api/data_types/string>`   | ✓         |        |
| `Parent<toolbar.parent>`                           | `Control</api/deprecated/control>` |           |        |
| `Tooltip<toolbar.tooltip>`                         | `String</api/data_types/string>`   |           |        |
| `Transparent<toolbar.transparent>`                 | `Boolean</api/data_types/boolean>` |           |        |
| `TrueWindow<toolbar.truewindow>`                   | `Window</api/deprecated/window>`   | ✓         |        |
| `Visible<toolbar.visible>`                         | `Boolean</api/data_types/boolean>` |           |        |
| `Width<toolbar.width>`                             | `Integer</api/data_types/integer>` |           |        |
| `Window<toolbar.window>`                           | `Window</api/deprecated/window>`   | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                           | Parameters                                                                                                                | Returns                                    | Shared |
|------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|--------------------------------------------|--------|
| `AcceptFileDrop<toolbar.acceptfiledrop>`       | FileType As `String</api/data_types/string>`                                                                              |                                            |        |
| `AcceptPictureDrop<toolbar.acceptpicturedrop>` |                                                                                                                           |                                            |        |
| `AcceptRawDataDrop<toolbar.acceptrawdatadrop>` | Type As `String</api/data_types/string>`                                                                                  |                                            |        |
| `AcceptTextDrop<toolbar.accepttextdrop>`       |                                                                                                                           |                                            |        |
| `AddButton<toolbar.addbutton>`                 | button As `ToolbarItem</api/deprecated/toolbaritem>`                                                                      |                                            |        |
| `AddButtonAt<toolbar.addbuttonat>`             | index As `Integer</api/data_types/integer>`, button As `ToolbarItem</api/deprecated/toolbaritem>`                         |                                            |        |
| `ButtonAt<toolbar.buttonat>`                   | index As `Integer</api/data_types/integer>`                                                                               | `ToolbarItem</api/deprecated/toolbaritem>` |        |
| `Close<toolbar.close_method>`                  |                                                                                                                           |                                            |        |
| `Count<toolbar.count>`                         |                                                                                                                           | `Integer</api/data_types/integer>`         |        |
| `DrawInto<toolbar.drawinto>`                   | g As `Graphics</api/graphics/graphics>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>` |                                            |        |
| `Invalidate<toolbar.invalidate>`               | \[EraseBackground As `Boolean</api/data_types/boolean>`\]                                                                 |                                            |        |
| `Refresh<toolbar.refresh>`                     | eraseBackground As `Boolean</api/data_types/boolean>`                                                                     |                                            |        |
| `RemoveButtonAt<toolbar.removebuttonat>`       | index As `Integer</api/data_types/integer>`                                                                               |                                            |        |
| `SetFocus<toolbar.setfocus>`                   |                                                                                                                           |                                            |        |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                                             | Parameters                                                                                          | Returns |
|--------------------------------------------------|-----------------------------------------------------------------------------------------------------|---------|
| `Action<toolbar.action>`                         | item As `ToolItem</api/deprecated/toolitem>`                                                        |         |
| `Close<toolbar.close_event>`                     |                                                                                                     |         |
| `DropDownMenuAction<toolbar.dropdownmenuaction>` | item As `ToolbarItem</api/deprecated/toolbaritem>`, hitItem As `MenuItem</api/deprecated/menuitem>` |         |
| `Open<toolbar.open>`                             |                                                                                                     |         |

## Property descriptions

<div id="toolbar.allowautodeactivate">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.AllowAutoDeactivate

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

Determines whether the control should be deactivated (on macOS) when the parent window is deactivated. The default is `True</api/language/true>`.

<div id="toolbar.allowtabstop">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.AllowTabStop

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

If `True</api/language/true>`, the **RectControl** is in the Tab Order and accepts the focus when the user tabs into it. The default is `True</api/language/true>`. If `False</api/language/false>`, the user cannot tab into it to give it the focus. However, the **RectControl** can gain the focus by other means, such as the user's clicking on it or by setting the focus in code.

This example removes the control from the Tab Order:

``` xojo
Me.AllowTabStop = False
```

<div id="toolbar.enabled">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.Enabled

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

Determines if the control should be enabled when the owning window is opened.

A disabled control cannot be clicked and cannot receive the focus.

This example disables the control. Its caption is grayed out.

``` xojo
Me.Enabled = False
```

<div id="toolbar.handle">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.Handle

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

Returns a handle to the control.

This property is read-only.

For interfacing with Mac APIs using `` Declare</api/language/declare>`s, RectControl.Handle returns NSViews (except for `Toolbar ``).

On Windows returns the HWND of the control.

On Linux it returns a GtkWidget.

The following gets a handle to the control.

``` xojo
Var i As Integer = Me.Handle
```

<div id="toolbar.height">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.Height

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

The height (in points) of the control.

This example sets the height of the control to 100:

``` xojo
Me.Height = 100
```

<div id="toolbar.name">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.Name

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

The name of the control. Set the name of the control in the Inspector.

This property is read-only.

<div id="toolbar.parent">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.Parent

**Parent** As `Control</api/deprecated/control>`

Used to get and set the control's parent control or window.

Returns `Nil</api/language/nil>` if the parent is the window. Assign `Nil</api/language/nil>` to make the control's parent the window, even if it is enclosed by another control. The child control's behavior in the IDE will reflect the parent's state. If the parent control is somehow in another window, an `InvalidParentException</api/exceptions/invalidparentexception>` will occur.

The following example sets the parent of the control to the window.

``` xojo
Me.Parent = Nil
```

<div id="toolbar.tooltip">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.Tooltip

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

Text of help message displayed as a Windows or Linux "tooltip" or macOS help tag.

The tip/tag is displayed when the user hovers the mouse cursor over the control.

This example adds a tooltip to a `BevelButton</api/deprecated/bevelbutton>` that has an icon.

``` xojo
Me.CaptionAlignment = 0 ' left
Me.CaptionDelta = 10
Me.Tooltip = "Click to bark."

Me.Icon = Woof ' added to the project
Me.CaptionPosition = 2
```

<div id="toolbar.transparent">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.Transparent

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

Determines whether the control is transparent on Windows. The default is `False</api/language/false>`. Has no effect on macOS or Linux.

Transparent controls draw more slowly and use more memory in order to cache the background. Unless you absolutely require transparency, leave this set to False.

For projects that were created prior to 2018r1, this property defaults to True to emulate previous behavior. Consider changing it to False to improve performance if you do not require transparency.

<div id="toolbar.truewindow">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.TrueWindow

**TrueWindow** As `Window</api/deprecated/window>`

Returns a reference to the actual enclosing `Window</api/deprecated/window>`.

This property is read-only.

TrueWindow walks up the window hierarchy and finds the actual enclosing window regardless of how deeply nested the `RectControl</api/deprecated/rectcontrol>` or `DesktopContainer</api/user_interface/desktop/desktopcontainer>` hierarchy is.

`Window</api/deprecated/window>` also has a TrueWindow property.

This example accesses the TrueWindow and displays its Title property in a `TextField</api/deprecated/textfield>`.

``` xojo
TextField1.Text = Me.TrueWindow.Title
```

<div id="toolbar.visible">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.Visible

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

Determines whether the control is visible when its owning window is opened. The default is `True</api/language/true>`: the control is visible.

The following code in the DisclosureTriangle Action event handler displays or hides a ListBox on the window:

``` xojo
ListBox1.Value = Me.Visible
```

<div id="toolbar.width">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.Width

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

The width (in points) of the control.

The following example resizes the control:

``` xojo
Me.Width = 200
```

<div id="toolbar.window">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.Window

**Window** As `Window</api/deprecated/window>`

The control's parent window.

This property is read-only.

This code gets the parent window's Title property.

``` xojo
TextField1.Text = Me.Window.Title
```

## Method descriptions

<div id="toolbar.acceptfiledrop">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.AcceptFileDrop

**AcceptFileDrop**(FileType As `String</api/data_types/string>`)

Permits documents of type *FileType* to be dropped on the control. *FileType* must be a file type that you defined in via the `FileType</api/files/filetype>` class or the File Type Sets Editor.

This code in the Open event of an `ImageWell</api/deprecated/imagewell>` makes it possible for the user to drop either a picture or a file that is a jpeg image. The File Type Sets editor was used to define the “image/jpeg” file type. It is one of the “Common File Types” that is available in the editor.

``` xojo
Me.AcceptPictureDrop
Me.AcceptFileDrop("image/jpeg")
```

To restrict file drops to just folders (and not files), you can put this code in the `DragEnter<rectcontrol.dragenter>` event:

``` xojo
If Not obj.FolderItem.IsFolder Then Return True
```

<div id="toolbar.acceptpicturedrop">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.AcceptPictureDrop

**AcceptPictureDrop**

Permits pictures to be dropped on the control.

If a control should accept pictures in a drag and drop, then AcceptPictureDrop needs to be called prior to the drop. Typically, it is in the Open event of the control itself. For example, the line:

``` xojo
Me.AcceptPictureDrop
```

in the Open event of the control that will receive the dragged pictures is needed. When the picture is dropped, the `DropObject<rectcontrol.dropobject>` event is called and this is where you will put your code to handle the drop.

Canvas.Open:

``` xojo
Me.AcceptPictureDrop
```

Canvas.DropObject:

``` xojo
If obj.PictureAvailable Then
  Me.Backdrop = obj.Picture
End If
```

<div id="toolbar.acceptrawdatadrop">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.AcceptRawDataDrop

**AcceptRawDataDrop**(Type As `String</api/data_types/string>`)

Permits data (of the Type specified) to be dropped on the control.

The following specfies a generic file type defined in the File Type Sets editor.

``` xojo
Me.AcceptRawDataDrop("????")
```

<div id="toolbar.accepttextdrop">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.AcceptTextDrop

**AcceptTextDrop**

Permits text to be dropped on the control.

This line in the Open event of a control that can accept dragged text.

``` xojo
Me.AcceptTextDrop
```

<div id="toolbar.addbutton">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.AddButton

**AddButton**(button As `ToolbarItem</api/deprecated/toolbaritem>`)

Adds the passed `ToolbarItem</api/deprecated/toolbaritem>` as the last element of the <span class="title-ref">Toolbar</span>.

<div id="toolbar.addbuttonat">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.AddButtonAt

**AddButtonAt**(index As `Integer</api/data_types/integer>`, button As `ToolbarItem</api/deprecated/toolbaritem>`)

Inserts the passed `ToolbarItem</api/deprecated/toolbaritem>` in the position indicated by *Index*.

<div id="toolbar.buttonat">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.ButtonAt

**ButtonAt**(index As `Integer</api/data_types/integer>`) As `ToolbarItem</api/deprecated/toolbaritem>`

Returns the `ToolbarItem</api/deprecated/toolbaritem>` specified by *Index*.

<div id="toolbar.close_method">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.Close

**Close**

Closes a control.

Closing a control permanently removes the control from memory, making it impossible to access. You can close both non-indexed controls and indexed controls. When you close an indexed control, the indexes for the remaining controls will shift downward so that the indexes start with zero and are consecutive.

The following code closes the control. When this is executed from a visible control, the control disappears from the window.

``` xojo
Me.Close
```

<div id="toolbar.count">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.Count

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

The number of ToolItems in the <span class="title-ref">Toolbar</span>.

<div id="toolbar.drawinto">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.DrawInto

**DrawInto**(g As `Graphics</api/graphics/graphics>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`)

Draws the contents of the RectControl into the specified `Graphics</api/graphics/graphics>` context. The parameters *x* and *y* are the coordinates of the top, left corner.

This method does not work with `HTMLViewer</api/deprecated/htmlviewer>` and `OpenGLSurface</api/deprecated/openglsurface>`.

This example draws the current control into the Graphics of a Picture and then displays it as the Backdrop of a Canvas:

``` xojo
Var p As New Picture(Me.Width, Me.Height)
Me.DrawInto(p.Graphics, 0, 0)
Canvas1.Backdrop = p
```

<div id="toolbar.invalidate">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.Invalidate

**Invalidate**(\[EraseBackground As `Boolean</api/data_types/boolean>`\])

Similar to RefreshRect, but causes the specified region of the RectControl to be marked dirty and to be redrawn when the window contents need to be redrawn. The region to be redrawn is specified by the *X*, *Y*, *Width*, and *Height* parameters. This form of Invalidate was formerly called InvalidateRect.

The following code refreshes the control. EraseBackground defaults to `True</api/language/true>`.

``` xojo
Me.Invalidate(False)
```

<div id="toolbar.refresh">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.Refresh

**Refresh**(eraseBackground As `Boolean</api/data_types/boolean>`)

Repaints the portion specified of the contents of the control immediately.

Calling this frequently can cause the code executing to slow down. It is often preferable to call `RectControl<rectcontrol.invalidate>` instead.

Refresh the entire area:

``` xojo
Me.Refresh(False)
```

Refresh a portion of the area:

``` xojo
Me.Refresh(100, 150, 200, 300)
```

<div id="toolbar.removebuttonat">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.RemoveButtonAt

**RemoveButtonAt**(index As `Integer</api/data_types/integer>`)

Removes the passed item from the <span class="title-ref">Toolbar</span>.

<div id="toolbar.setfocus">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.SetFocus

**SetFocus**

If applicable, sets the focus to the RectControl. KeyDown events are directed to the control.

If the control cannot get the focus on the platform on which the application is running, SetFocus does nothing. The SetFocus method of the `Window</api/deprecated/window>` class or the `ClearFocus</api/user_interface/desktop/clearfocus>` method can be used to remove the focus from the control that currently has the focus, leaving no control with the focus.

On the Mac you need Full Keyboard Access turned on in System Preferences (Keyboard-\>Shortcuts) in order to manually set focus to non-text controls.

The following example sets the focus to TextField1. If another control has the focus when this line is executed, then the user sees that TextField1 gets the focus.

``` xojo
TextField1.SetFocus
```

## Event descriptions

<div id="toolbar.action">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.Action

**Action**(item As `ToolItem</api/deprecated/toolitem>`)

The passed item was clicked.

<div id="toolbar.close_event">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.Close

**Close**

The control is about to close.

<div id="toolbar.dropdownmenuaction">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.DropDownMenuAction

**DropDownMenuAction**(item As `ToolbarItem</api/deprecated/toolbaritem>`, hitItem As `MenuItem</api/deprecated/menuitem>`)

The passed `ToolbarItem</api/deprecated/toolbaritem>` was chosen from the passed `MenuItem</api/deprecated/menuitem>`.

<div id="toolbar.open">

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

</div>

<div class="rst-class">

forsearch

</div>

Toolbar.Open

**Open**

The control is about to be displayed. Use this event to initialize a control.

The Open event is called after the Constructor.

Be warned that initializing control property values using the Constructor instead of the Open event may result in those property values being overwritten by what is set in the Inspector. For best results, use the Open event for control initialization rather than the control Constructor.

If the control is supposed to handle drag and drop, you need to tell it which type of item it needs to be able to handle. The following example informs the control that pictures and files can be dropped on it. The type of the file it needs to support is specified via the File Types Editor.

``` xojo
Sub Open()
  Me.AcceptPictureDrop
  Me.AcceptFileDrop("JPEG")
End Sub
```

## Notes

A <span class="title-ref">Toolbar</span> object contains all the buttons in a <span class="title-ref">Toolbar</span>. You create the items in the <span class="title-ref">Toolbar</span> with the `ToolbarButton</api/deprecated/toolbarbutton>` class and add them to the <span class="title-ref">Toolbar</span> with the `AddButton<toolbar.addbutton>` or `AddButtonAt<toolbar.addbuttonat>` methods. An item can be either a button or a divider. A button can work as either a pushbutton or a toggle button.

<div class="note">

<div class="title">

Note

</div>

For best results, you should ensure that all your <span class="title-ref">Toolbar</span> icons are the same size. Some platforms will size all icons to that of the icon on the first button in the <span class="title-ref">Toolbar</span>.

</div>

<div class="warning">

<div class="title">

Warning

</div>

You can only have a single <span class="title-ref">Toolbar</span> on a Window.

</div>

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

### Mouse events

Although <span class="title-ref">Toolbar</span> inherits from `RectControl</api/deprecated/rectcontrol>`, it has no mouse-related events. This is due to limitations of the operating system.

## Sample code

This example shows how to create a <span class="title-ref">Toolbar</span> via code. It builds a small <span class="title-ref">Toolbar</span> with Open and Save buttons. A <span class="title-ref">Toolbar</span> object was added to a window. The pictures that are displayed by the two buttons were added to the project.

The window has the following properties:

``` xojo
SaveButton As ToolbarButton
OpenButton As ToolbarButton
```

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

The following code is in the `Open<control.open>` event of the <span class="title-ref">Toolbar</span> instance in the window.

``` xojo
SaveButton = New ToolbarButton
OpenButton = New ToolbarButton

SaveButton.Caption = "Save" ' Caption appears below the Icon
SaveButton.Name = "Save"
SaveButton.icon = SaveButtonImage ' image added to the project

OpenButton.Caption = "Open" ' Caption appears below the Icon
OpenButton.Name = "Open"
OpenButton.Icon = OpenButtonImage ' image added to the project
SaveButton.Style = ToolbarButton.ButtonStyles.PushButton
OpenButton.Style = ToolbarButton.ButtonStyles.PushButton

' add to the Toolbar
Me.AddButton(OpenButton)
Me.AddButton(SaveButton)
```

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

The following code is in the `Action<toolbar.action>` event of the <span class="title-ref">Toolbar</span> in the window:

``` xojo
Sub Action(item As ToolItem)
  Select Case item.Name
  Case "Open"
    MessageBox("You clicked the Open Button.")
  Case "Save"
    MessageBox("You clicked the Save Button.")
  End Select
End Sub
```

## Compatibility

All project types on all supported operating systems.

## See also

`RectControl</api/deprecated/rectcontrol>` parent class; `ToolbarButton</api/deprecated/toolbarbutton>`, `ToolbarItem</api/deprecated/toolbaritem>` classes.
