123456789_123456789_123456789_123456789_123456789_

Class: Sketchup::ViewObserver Abstract

Relationships
Inherits: Object

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

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:

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:

Version:

  • SketchUp 6.0