# Hide tray using api

**URL:** <https://forums.sketchup.com/t/hide-tray-using-api/344123>\
**Category:** Ruby API\
**Tags:** advice, mac\
**Created:** [January 26, 2026, 10:32pm UTC](https://forums.sketchup.com/t/hide-tray-using-api/344123 "2026-01-26T22:32:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Evzyl](https://avatars.discourse-cdn.com/v4/letter/e/9e8a1a/32.png) [@Evzyl](https://forums.sketchup.com/u/Evzyl)\
**Post date:** [January 26, 2026, 10:32pm UTC](https://forums.sketchup.com/t/hide-tray-using-api/344123/1 "2026-01-26T22:32:18Z")

</div>

Hello im working on an extension that tries to overwride the default tools, while in a work mode. This is necessary for using the keyboard to type directly using a bottom ui and for other reasons. Im facing a limitation whit the overwriting of the paint bucket tool, i can overwrite it like other tools, but while it gets selected before being overwritten it automatically opens the tray. I dint find any way to cancel this automatic tray opening by the paint bucket in the api, i know there is a mac option but there is no api option. I cannot cancel a default tool, only overwrite it, and there is no observer that can run before the tools either. Maybe i can get some ideas for this i would really apreciate any help. Thanks

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [January 27, 2026, 1:05am UTC](https://forums.sketchup.com/t/hide-tray-using-api/344123/2 "2026-01-27T01:05:49Z")

</div>

The only control the Ruby API currently gives is to **open** inspector panels.

- [`UI.show_inspector`](https://ruby.sketchup.com/UI.html#show_inspector-class_method)

There is a remote possibility. Since the user can create ANY named custom tray in which to dock the **Materials** panel, you could have the user assign a custom shortcut to **Toggle Visibility** for that tray, …  
… then you use a trick to send keystrokes to SketchUp for that menu shortcut.

On the Mac, this requires a 3rd party utility called **cliclick**.

On Windows, you can use the Windows Scripting Host’s **SendKeys** method via Ruby’s [`WIN32OLE`](https://docs.ruby-lang.org/en/3.2/WIN32OLE.html) class.

For example’s sake, say that the user tells you via an inpubox that the shortcut they’ve chosen is ALT+F8

```ruby
module Evzyl
  module MyTools

    # Set a default shortcut to toggle the Materials panel tray.
    # This can be changed at anytime after loading extension.
    @matls_shorcut ||= '%{F8}'

    def toggle_materials_panel
      require 'win32ole' unless defined?(WIN32OLE)
      WIN32OLE.new('WScript.Shell').SendKeys(@matls_shorcut)
    end

  end
end

```

REF: [SendKeys method - Windows Script Host](https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/windows-scripting/8c6yea83(v=vs.84)?redirectedfrom=MSDN)

* * *

A **very** advanced pattern might be to read the user’s shortcut setting from the `"SharedPreferences.json"` file. (This file is located in different places on Mac and Windows.)

---

<div class="post-metadata">

**Author:** ![Evzyl](https://avatars.discourse-cdn.com/v4/letter/e/9e8a1a/32.png) [@Evzyl](https://forums.sketchup.com/u/Evzyl)\
**Post date:** [January 27, 2026, 10:09am UTC](https://forums.sketchup.com/t/hide-tray-using-api/344123/3 "2026-01-27T10:09:30Z")

</div>

Thanks a lot for taking ur time and helping whit my issue this means a lot for me, as i really wish to create a quality extension, this issue really felt like a brick wall for me and any kind of help is apreciated! I will try ur method and have a settings section where users can work around and disable this tray by providing a shortcut to sketchup. My actual goal is to prevent SketchUp’s Paint tool from activating (and popping the Materials tray) while our custom tool is active. I’ve already tried:

- `ToolsObserver#onActiveToolChanged` to immediately reselect our custom tool when Paint activates.

- A fast UI.start\_timer monitor that detects `PAINT_TOOL_ID` and calls select\_tool(nil), Sketchup.send\_action(‘cancelOperation:’) and then reselects our custom tool.

These stop the tool quickly, but the tray still opens as it gets the oportunity to run even for a frame.

If u are willing to help are there any supported way to temporarily block the Paint tool (or default Sketchup tools) while a Ruby tool is active? Or any lower‑level hook that fires before SketchUp switches tools? Or any way to make a tool that uses the keyboard freely without any default Sketchup tool intervention? thanks so much again for your time!

---

<div class="post-metadata">

**Author:** ![Evzyl](https://avatars.discourse-cdn.com/v4/letter/e/9e8a1a/32.png) [@Evzyl](https://forums.sketchup.com/u/Evzyl)\
**Post date:** [January 27, 2026, 1:53pm UTC](https://forums.sketchup.com/t/hide-tray-using-api/344123/4 "2026-01-27T13:53:53Z")

</div>

I recently applied your method and was able to find the tray “Toggle Visibility” shortcut in preferences. When I press the Paint tool shortcut (B), the tray still appears for a frame, then disappears using the shortcut hack. So it doesn’t fully solve the keyboard problem in my extension.

Because the tray flashes open, I can’t reliably use the full window for my custom bottom UI. In practice, users would need to keep the side tray open all the time, which isn’t acceptable. That means I likely need to abandon this keyboard approach and try something else.

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [January 27, 2026, 8:52pm UTC](https://forums.sketchup.com/t/hide-tray-using-api/344123/5 "2026-01-27T20:52:30Z")

</div>

> [@Evzyl](#):
>
> … are there any supported way to temporarily block the Paint tool (or default Sketchup tools) while a Ruby tool is active?

I do not think so. Supposedly, according to the API docs, the keystroke callbacks will not bubble up if **`true`** is returned, but I do not remember this ever preventing shortcuts from changing the tool.

> [@Evzyl](#):
>
> Or any lower‑level hook that fires before SketchUp switches tools?

No, I know of none. The [`ToolsObserver#onActiveToolChanged`](https://ruby.sketchup.com/Sketchup/ToolsObserver.html#onActiveToolChanged-instance_method) callback is triggered in the past tense (i.e., after the tool has changed.)

> [@Evzyl](#):
>
> Or any way to make a tool that uses the keyboard freely without any default Sketchup tool intervention?

Again, no not at this time. It **is** a common complaint by tool coders.

> [@Evzyl](#):
>
> I recently applied your method and was able to find the tray “Toggle Visibility” shortcut in preferences. When I press the Paint tool shortcut (B), the tray still appears for a frame, then disappears using the shortcut hack. So it doesn’t fully solve the keyboard problem in my extension.

**Correct**. There is no **current** way to prevent the panel from popping up. It is not just coders, but everyday users are also complaining that there is no way to stop the panel from seizing the keyboard focus. Some users want to use the Paint Sampling feature of the tool and **not** the Materials inspector, so they’ve asked for a switch the tell SketchUp not to activate the tray panel.

> [@Evzyl](#):
>
> Because the tray flashes open, I can’t reliably use the full window for my custom bottom UI. In practice, users would need to keep the side tray open all the time, which isn’t acceptable. That means I likely need to abandon this keyboard approach and try something else.

There is nothing else to try, that is exposed to the Ruby API.

* * *

> [@Evzyl](#):
>
> `Sketchup.send_action("cancelOperation:")`

FYI, This has no effect on MS Windows. It’s a **Mac only** action string. See my old example:

[[Example] Send Escape Key - Cancel Operation script](https://forums.sketchup.com/t/example-send-escape-key-cancel-operation-script/115062)

* * *

> [@Evzyl](#):
>
> Hello im working on an extension that tries to _override_ the default tools, while in a work mode. This is necessary for using the keyboard to type directly using a bottom _UI_ …

**Probably not a very good idea**. It sounds like you are trying to make SketchUp work like ACAD’s command driven interface. SketchUp was purposefully designed to **NOT** be like CAD. It has been called “the unCAD”. SketchUp has a tool driven interface where there is always an active tool that the user uses to interact with the geometry.

I would **guess** that Trimble _may_ take a dim view of an extension that interferes with SketchUp’s default tools. I suggest reading the Terms of Service carefully before releasing anything that does what you describe.

It will always be **more acceptable** to create your own palette of custom tools rather than circumvent the default tools.

---

<div class="post-metadata">

**Author:** ![ryan.moore](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/ryan.moore/32/106089_2.png) [@ryan.moore](https://forums.sketchup.com/u/ryan.moore)\
**Post date:** [January 27, 2026, 8:58pm UTC](https://forums.sketchup.com/t/hide-tray-using-api/344123/6 "2026-01-27T20:58:45Z")

</div>

> [@DanRathbun](#):
>
> Some users want to use the Paint Sampling feature of the tool and **not** the Materials inspector, so they’ve asked for a switch the tell SketchUp not to activate the tray panel.

Hey, not sure if you were aware, this exists on Mac. When checked the materials panel opens when the paint tool is activated, when unticked it does not.

 ![Screen Shot 2026-01-27 at 3.56.08 PM](https://global.discourse-cdn.com/sketchup/original/3X/e/3/e3030b09605b2d0ae25b2f39e7f19980f8eb0d97.png)

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [January 27, 2026, 9:08pm UTC](https://forums.sketchup.com/t/hide-tray-using-api/344123/7 "2026-01-27T21:08:29Z")

</div>

No we do **not** have that option on MS Windows in either 2025 or 2026 versions.

---

<div class="post-metadata">

**Author:** ![ryan.moore](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/ryan.moore/32/106089_2.png) [@ryan.moore](https://forums.sketchup.com/u/ryan.moore)\
**Post date:** [January 27, 2026, 9:09pm UTC](https://forums.sketchup.com/t/hide-tray-using-api/344123/8 "2026-01-27T21:09:18Z")

</div>

Been on Mac since I started using SketchUp. That said the rest of the materials handling on mac is a train wreck lol.

---

<div class="post-metadata">

**Author:** ![Evzyl](https://avatars.discourse-cdn.com/v4/letter/e/9e8a1a/32.png) [@Evzyl](https://forums.sketchup.com/u/Evzyl)\
**Post date:** [January 28, 2026, 12:03am UTC](https://forums.sketchup.com/t/hide-tray-using-api/344123/9 "2026-01-28T00:03:42Z")

</div>

Thanks a lot for your time and help — and for the warning as well.  
I’ll try to build something that I believe SketchUp lacks in the woodworking space, and I’ll worry about the terms later.  
I’m looking forward to coming back here and posting about my struggles on this journey.  
I’m really grateful for the help and for this forum.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sketchup/original/3X/f/2/f2a121500b085ed60806607a82720b092d800bb3.png) [@system](https://forums.sketchup.com/u/system)\
**Post date:** [February 4, 2026, 12:03am UTC](https://forums.sketchup.com/t/hide-tray-using-api/344123/10 "2026-02-04T00:03:46Z")

</div>

Closed on February 4, 2026, 12:03am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
