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

**URL:** <https://forums.sketchup.com/t/cursor-doesnt-change-on-mac-when-activating-a-tool-from-ruby-api/60921>\
**Category:** Ruby API\
**Created:** [January 31, 2018, 9:53am UTC](https://forums.sketchup.com/t/cursor-doesnt-change-on-mac-when-activating-a-tool-from-ruby-api/60921 "2018-01-31T09:53:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![timucin.kabak](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@timucin.kabak](https://forums.sketchup.com/u/timucin.kabak)\
**Post date:** [January 31, 2018, 9:53am UTC](https://forums.sketchup.com/t/cursor-doesnt-change-on-mac-when-activating-a-tool-from-ruby-api/60921/1 "2018-01-31T09:53:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![john\_drivenupthewall](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@john\_drivenupthewall](https://forums.sketchup.com/u/john_drivenupthewall)\
**Post date:** [January 31, 2018, 10:44am UTC](https://forums.sketchup.com/t/cursor-doesnt-change-on-mac-when-activating-a-tool-from-ruby-api/60921/2 "2018-01-31T10:44:38Z")

</div>

the mac issue is with window focus…

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

```ruby
# 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…

```ruby
 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

---

<div class="post-metadata">

**Author:** ![timucin.kabak](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@timucin.kabak](https://forums.sketchup.com/u/timucin.kabak)\
**Post date:** [January 31, 2018, 11:21am UTC](https://forums.sketchup.com/t/cursor-doesnt-change-on-mac-when-activating-a-tool-from-ruby-api/60921/3 "2018-01-31T11:21:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![john\_drivenupthewall](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@john\_drivenupthewall](https://forums.sketchup.com/u/john_drivenupthewall)\
**Post date:** [January 31, 2018, 11:41am UTC](https://forums.sketchup.com/t/cursor-doesnt-change-on-mac-when-activating-a-tool-from-ruby-api/60921/4 "2018-01-31T11:41:39Z")

</div>

> [@timucin.kabak](#):
>
> de\_focus trick didn’t work.

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

---

<div class="post-metadata">

**Author:** ![timucin.kabak](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@timucin.kabak](https://forums.sketchup.com/u/timucin.kabak)\
**Post date:** [January 31, 2018, 11:59am UTC](https://forums.sketchup.com/t/cursor-doesnt-change-on-mac-when-activating-a-tool-from-ruby-api/60921/5 "2018-01-31T11:59:30Z")

</div>

@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

```

---

<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:** [May 3, 2018, 3:59am UTC](https://forums.sketchup.com/t/cursor-doesnt-change-on-mac-when-activating-a-tool-from-ruby-api/60921/6 "2018-05-03T03:59:34Z")

</div>

Closed on May 3, 2018, 3:59am UTC

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