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

Hi,

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.
SKETCHUP_CONSOLE.hide
Sketchup.send_action('selectPaintTool:')
# or for one of my own tools I may use
# Sketchup.active_model.select_tool(JcB::Selector.new)

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 = UI::WebDialog.new('noDlg', false, '', 0, 0, 0, 0, false) unless defined? NODLG
 # move focus to main window...
 def de_focus
 NODLG.show
 NODLG.close
 end

then you can call #de_focus after triggering your tool…

john

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…

UI::WebDialog.new('noDlg', false, '', 0, 0, 0, 0, false)

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

john

@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 = UI::HtmlDialog.new(
  {
    :dialog_title => "dummy",
    :scrollable => false,
    :resizable => true,
    :width => 0,
    :height => 0,
    :left => 0,
    :top => 0
  })
  dummieDlg.show()
  UI.start_timer(0.5, false) { 
    dummieDlg.close  
  }
end

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