Class: Sketchup::ViewObserver Abstract

Inherits:
Object
  • Object
show all

Overview

This class is abstract.

To implement this observer, create a Ruby class of this type, override the desired methods, and add an instance of the observer to the View object.

This observer interface is implemented to react to View events.

Examples:

class MyViewObserver < Sketchup::ViewObserver
  def onViewChanged(view)
    puts "onViewChanged: #{view}"
  end
end

Sketchup.active_model.active_view.add_observer(MyViewObserver.new)

See Also:

Version:

  • SketchUp 6.0

Instance Method Summary # collapse

Instance Method Details

#onScaleFactorChange(view) ⇒ nil

The #onScaleFactorChange method is called whenever the view DPI of the view changes. This can be the SketchUp window being moved to another monitor with a different DPI or the user changing the DPI settings of the monitor.

Examples:

class MyViewObserver < Sketchup::ViewObserver
  def onScaleFactorChange(view)
    puts "onScaleFactorChange: #{view}"
    puts "UI.scale_factor(view): #{UI.scale_factor(view)}"
  end
end

Sketchup.active_model.active_view.add_observer(MyViewObserver.new)

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 2025.0

#onViewChanged(view) ⇒ nil

The #onViewChanged method is called whenever the view is altered, such as when the user uses the Pan, Orbit, or Zoom tools.

Examples:

class MyViewObserver < Sketchup::ViewObserver
  def onViewChanged(view)
    puts "onViewChanged: #{view}"
  end
end

Sketchup.active_model.active_view.add_observer(MyViewObserver.new)

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 6.0

Known Bugs:

  • Prior to SketchUp 2019.2 this event did not trigger when the viewport size changed.