Class: Sketchup::SelectionObserver 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 objects of interests.

This observer interface is implemented to react to selection events.

Examples:

# This is an example of an observer that watches the selection for
# changes.
class MySelectionObserver < Sketchup::SelectionObserver
  def onSelectionBulkChange(selection)
    puts "onSelectionBulkChange: #{selection}"
  end
end

# Attach the observer.
Sketchup.active_model.selection.add_observer(MySelectionObserver.new)

Version:

  • SketchUp 6.0

Instance Method Summary # collapse

Instance Method Details

#onSelectionAdded(selection, entity) ⇒ nil

Note:

This event might not trigger even if a single element is selected. For instance the Selection tool will trigger #onSelectionBulkChange regardless.

Examples:

def onSelectionAdded(selection, entity)
  puts "onSelectionAdded: #{entity}"
end

Parameters:

Returns:

  • (nil)

See Also:

Version:

  • SketchUp 6.0

#onSelectionBulkChange(selection) ⇒ nil

The #onSelectionBulkChange method is called whenever items are added or removed from the selection set.

The #onSelectionBulkChange callback will not trigger if the selection is cleared by clicking on empty model space. Use the #onSelectionCleared method to catch this case.

Examples:

def onSelectionBulkChange(selection)
  puts "onSelectionBulkChange: #{selection}"
end

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 6.0

#onSelectionCleared(selection) ⇒ nil

The #onSelectionCleared method is called when the selection is completely emptied.

Examples:

def onSelectionCleared(selection)
  puts "onSelectionCleared: #{selection}"
end

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 6.0

#onSelectionRemoved(selection, entity) ⇒ nil

Note:

This event might not trigger even if a single element is deselected. For instance the Selection tool will trigger #onSelectionBulkChange regardless.

Examples:

class MySelectionObserver < Sketchup::SelectionObserver
 def onSelectionRemoved(selection, entity)
   puts "onSelectionRemoved: #{entity}"
 end

 # Due to a SketchUp bug, this method is called by the wrong name.
 alias_method :onSelectedRemoved, :onSelectionRemoved
end

# Attach the observer.
Sketchup.active_model.selection.add_observer(MySelectionObserver.new)

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 6.0

Known Bugs:

  • Due to a bug in SketchUp this event doesn't trigger. Instead onSelectedRemoved is called.