Cursor doesn't change on Mac when activating a tool from Ruby API


I have two commands in my plugin code.

One of them uses Sketchup.send_action() to activate paint bucket tool.

The other one is a custom tool I created to mimic eye dropper functionality.

Both of them works functionally as expected on PC and Mac.

But on Mac, for the cursor to change into the related icon, I need to click on the scene once.

Does anyone know how to fix this issue?

Kind regards.

the mac issue is with window focus…

if calling from ‘Ruby Console’ you need to close it…

# move focus to SU viewport by closing RC.
# or for one of my own tools I may use
# Sketchup.active_model.select_tool(

if triggered from a menu item or a UI::Toolbar it should change, so I assume your using a Web or Html dialog…

moving focus from these is harder unless you simply close it. i.e. @my_dlg.close

the alternative is to ‘toggle’ a separate dialog…

 NODLG ='noDlg', false, '', 0, 0, 0, 0, false) unless defined? NODLG
 # move focus to main window...
 def de_focus

then you can call #de_focus after triggering your tool…


Like you guessed @john_drivenupthewall I’m triggering them from an HTMLDialog but unfortunately de_focus trick didn’t work. Do you have anything else you can suggest? For example, removing focus from HTMLDialog without closing it?

sorry the snippet was from memory…

I use it successfully in a number of plugins, but I do specify some options…

I’ll edit the code to include this…'noDlg', false, '', 0, 0, 0, 0, false)

in others i use a HtmlDialog, but it needs a timer…


@john_drivenupthewall I think WebDialog can’t steal focus from HTMLDialog. I made it work with the script below. Thanks for all your help.

def self.de_focus
  dummieDlg =
    :dialog_title => "dummy",
    :scrollable => false,
    :resizable => true,
    :width => 0,
    :height => 0,
    :left => 0,
    :top => 0
  UI.start_timer(0.5, false) { 

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