Overlay onMouseMove flags Bug on Mac

On mac, the custom Sketchup::Tool can correctly respond to onMouseMove’s flags, which can be used to determine when a key combination is pressed, such as ALT_MODIFIER_MASK + MK_LBUTTON

The test code is:

class MouseMoveTestTool
  def onMouseMove(flags, x, y, view)
    p 'Tool test start'
    p "flags & ALT_MODIFIER_MASK == ALT_MODIFIER_MASK: #{flags & ALT_MODIFIER_MASK == ALT_MODIFIER_MASK}"
    p "flags & MK_LBUTTON == MK_LBUTTON: #{flags & MK_LBUTTON == MK_LBUTTON}"
    p 'Tool test end'
    puts
  end
end

unless file_loaded?(__FILE__)
  file_loaded(__FILE__)
  UI.menu('Plugins').add_item('MouseMoveTestTool') { Sketchup.active_model.select_tool(MouseMoveTestTool.new) }
end

When ⌘Command + Left Mouse down, the output:

"Tool test start"
"flags & ALT_MODIFIER_MASK == ALT_MODIFIER_MASK: true"
"flags & MK_LBUTTON == MK_LBUTTON: true"
"Tool test end"

But, use the same code on Overlay, the flags MK_LBUTTON is lost,the test code is:

class MouseMoveTestOverlay < Sketchup::Overlay
  def initialize
    super('MouseMoveTestOverlay', 'Mouse Move Test Overlay')
  end

  def onMouseMove(flags, x, y, view)
    p 'Overlay test start'
    p "flags & ALT_MODIFIER_MASK == ALT_MODIFIER_MASK: #{flags & ALT_MODIFIER_MASK == ALT_MODIFIER_MASK}"
    p "flags & MK_LBUTTON == MK_LBUTTON: #{flags & MK_LBUTTON == MK_LBUTTON}"
    p 'Overlay test end'
    puts
  end
end

class OverlayAppObserver < Sketchup::AppObserver
  def expectsStartupModelNotifications
    true
  end

  def register_overlay(model)
    overlay = MouseMoveTestOverlay.new
    begin
      model.overlays.add(overlay)
      overlay.enabled = true unless overlay.enabled?
    rescue ArgumentError => error
      warn error
    end
  end

  alias_method :onNewModel, :register_overlay
  alias_method :onOpenModel, :register_overlay
end

Sketchup.add_observer(OverlayAppObserver.new)

When ⌘Command down, and ⌘Command + Left Mouse down, the output both are:

"Overlay test start"
"flags & ALT_MODIFIER_MASK == ALT_MODIFIER_MASK: true"
"flags & MK_LBUTTON == MK_LBUTTON: false"
"Overlay test end"

Looks like Left Mouse down flags are lost.

This might be intentional as picking things in an Overlay is not allowed.
Ie, overlays are not intended to be interactive, … only informational.


I do not see any of the MK_ prefixed constants listed in the API documentation.

@tt_su @ene_su @ChrisFullmer