# Set Toolbar Item Pushed State

**URL:** <https://forum.xojo.com/t/set-toolbar-item-pushed-state/8532>\
**Category:** General\
**Created:** [June 5, 2013, 3:51pm UTC](https://forum.xojo.com/t/set-toolbar-item-pushed-state/8532 "2013-06-05T15:51:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ian\_Farlow](https://forum.xojo.com/letter_avatar_proxy/v4/letter/i/94ad74/32.png) [@Ian\_Farlow](https://forum.xojo.com/u/Ian_Farlow)\
**Post date:** [June 5, 2013, 3:51pm UTC](https://forum.xojo.com/t/set-toolbar-item-pushed-state/8532/1 "2013-06-05T15:51:21Z")

</div>

I see how to set a toolbar item’s pushed state via the IDE, but how do I set it via code? I have checked the documentation but didn’t find anything that would point me in the right direction. To clarify: I’m speaking specifically of the pushed state of toggle buttons in a toolbar.

Thanks.

---

<div class="post-metadata">

**Author:** ![Frederick\_Roller](https://forum.xojo.com/user_avatar/forum.xojo.com/frederick_roller/32/479_2.png) [@Frederick\_Roller](https://forum.xojo.com/u/Frederick_Roller)\
**Post date:** [June 5, 2013, 3:56pm UTC](https://forum.xojo.com/t/set-toolbar-item-pushed-state/8532/2 "2013-06-05T15:56:20Z")

</div>

```auto
WebToolbarButton.Toggled = Not WebToolbarButton.Toggled
```

---

<div class="post-metadata">

**Author:** ![Ian\_Farlow](https://forum.xojo.com/letter_avatar_proxy/v4/letter/i/94ad74/32.png) [@Ian\_Farlow](https://forum.xojo.com/u/Ian_Farlow)\
**Post date:** [June 5, 2013, 3:59pm UTC](https://forum.xojo.com/t/set-toolbar-item-pushed-state/8532/3 "2013-06-05T15:59:02Z")

</div>

That appears to be only for web-based forms and I’m coding a desktop app. I should have clarified that. Sorry.

---

<div class="post-metadata">

**Author:** ![Paul\_Lefebvre](https://forum.xojo.com/user_avatar/forum.xojo.com/paul_lefebvre/32/3152_2.png) [@Paul\_Lefebvre](https://forum.xojo.com/u/Paul_Lefebvre)\
**Post date:** [June 5, 2013, 4:03pm UTC](https://forum.xojo.com/t/set-toolbar-item-pushed-state/8532/4 "2013-06-05T16:03:48Z")

</div>

This code will push a toggle button on a desktop toolbar. I just put it in the Open event handler of the Toolbar on the window:

```auto
ToolButton(Me.Item(0)).Pushed = True
```

---

<div class="post-metadata">

**Author:** ![Frederick\_Roller](https://forum.xojo.com/user_avatar/forum.xojo.com/frederick_roller/32/479_2.png) [@Frederick\_Roller](https://forum.xojo.com/u/Frederick_Roller)\
**Post date:** [June 5, 2013, 4:04pm UTC](https://forum.xojo.com/t/set-toolbar-item-pushed-state/8532/5 "2013-06-05T16:04:05Z")

</div>

```auto
ToolButton.Pushed = Not ToolButton.Pushed
```

It must have a Style of ToolStyleToggleButton.

---

<div class="post-metadata">

**Author:** ![Ian\_Farlow](https://forum.xojo.com/letter_avatar_proxy/v4/letter/i/94ad74/32.png) [@Ian\_Farlow](https://forum.xojo.com/u/Ian_Farlow)\
**Post date:** [June 5, 2013, 4:08pm UTC](https://forum.xojo.com/t/set-toolbar-item-pushed-state/8532/6 "2013-06-05T16:08:31Z")

</div>

Ah… thanks for the info. Just tried it out and it worked exactly as I expected. Much appreciated.

---

<div class="post-metadata">

**Author:** ![Tom\_Iwaniec](https://forum.xojo.com/user_avatar/forum.xojo.com/tom_iwaniec/32/345_2.png) [@Tom\_Iwaniec](https://forum.xojo.com/u/Tom_Iwaniec)\
**Post date:** [July 30, 2013, 9:55am UTC](https://forum.xojo.com/t/set-toolbar-item-pushed-state/8532/7 "2013-07-30T09:55:24Z")

</div>

Does this not work for Cocoa builds? It seems to not have any effect on the toolbutton when setting the style to ToolStyleToggleButton and the pushed to true.

---

<div class="post-metadata">

**Author:** ![Paul\_Lefebvre](https://forum.xojo.com/user_avatar/forum.xojo.com/paul_lefebvre/32/3152_2.png) [@Paul\_Lefebvre](https://forum.xojo.com/u/Paul_Lefebvre)\
**Post date:** [July 31, 2013, 9:12pm UTC](https://forum.xojo.com/t/set-toolbar-item-pushed-state/8532/8 "2013-07-31T21:12:14Z")

</div>

It looks like the Pushed property in the Inspector is not doing anything.

Setting it via code (see posts above) seems to work fine, though.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 4:41pm UTC](https://forum.xojo.com/t/set-toolbar-item-pushed-state/8532/9 "2020-10-29T16:41:52Z")

</div>


