Class: Sketchup::SelectionObserver Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb

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



45
46
# File 'lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb', line 45

def onSelectionAdded(selection, entity)
end

#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



65
66
# File 'lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb', line 65

def onSelectionBulkChange(selection)
end

#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



81
82
# File 'lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb', line 81

def onSelectionCleared(selection)
end

#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



112
113
# File 'lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb', line 112

def onSelectionRemoved(selection, entity)
end