Sketchup.send_action("selectPaintTool:") fails on SketchUp 2021 osx when called from HtmlDialog callback

Hi there,

For some reason I am having issues to activate the native paint tool when calling Sketchup.send_action("selectPaintTool:") on SketchUp 2021 osx when called from within an HtmlDialog callback. It seems to never activate the tool.

I thought it might be a focus problem, so I already tried the de_focus hack by creating another dialog and quickcly opening and closing that. Unfortunately that did not help.

So, I tried this:

model = Sketchup.active_model
tool = {}
def tool.onMouseMove(flags, x, y, view)
  Sketchup.send_action("selectPaintTool:")
end #def
model.select_tool(tool)

I mocked a fake tool who’s sole purpose is to activate the native one whenever the user moves the mouse and this fake tool is active. Seems to work fine :slight_smile: and I thus wanted to share this with you.

1 Like

Nice find,
Perhaps the #onMouseEnter(view) or #onMouseLeave(view) in your original Tool will work too…?

That might work as well. I went for onMouseMove because I want to force (:rage:) Sketchup with these send_action requests for as long as my tool is active, and thus the tool I want to be active is not :slight_smile:

As soon as the Paint tool activated you tool (or a fake tool) will be no longer active…
…or you mean that one call is “not enough” for OSX to get the #sent_action(), so you keep forcing by each mouse move until OSX “understand” what you want? :thinking:

I have no idea if one call is enough, I just wanted to be sure :wink:
It is the first method that came to my mind, didn’t try other ones.

This is interesting, one call should be enough.

It can also be the html callback were lost somehow.
I mean action callbacks are detached from the dialog somehow, e.g. if the dialog is close action callbacks are detached, then you did not attached it back properly?? :thinking:

The callbacks are attached and called properly.

1 Like

There are known issues with Mac and HtmlDialog callbacks …

Might as well open another issue.

BTW, is it only the Paint Bucket Tool, … or any tool ?

Yes, and I hate it :slight_smile:

Have only tried this one, since I encountered it making an extension for one of my customers.

When I have some more time I will setup a basic repo with an HtmlDialog and a few callbacks that trigger various of these send_command methods

1 Like