ModraUp Ruby API Documentation Ruby API Reference

Class: ModraUp::SelectionObserver

Inherits:
Object
  • Object
show all

Overview

The base class for selection observers. Plugins subclass it to implement onSelectionBulkChange / onSelectionCleared / onSelectionAdded / onSelectionRemoved.

Examples:

class MySel < ModraUp::SelectionObserver
  def onSelectionCleared(selection)
  end
end
ModraUp.active_model.selection.add_observer(MySel.new)

Instance Method Summary # collapse

Instance Method Details

observer.onSelectionBulkChange(selection) ⇒ nil

Called when the selection set is bulk-replaced (e.g., by picking or box-selecting).

Parameters:

  • selection (ModraUp::Selection)

Returns:

  • (nil)

Examples:

class MySel < ModraUp::SelectionObserver
  def onSelectionBulkChange(selection)
    selection.length
  end
end

observer.onSelectionAdded(selection, entity) ⇒ nil

Called when a single entity is added to the selection set.

Parameters:

  • selection (ModraUp::Selection)
  • entity (ModraUp::Entity)

Returns:

  • (nil)

Examples:

class MySel < ModraUp::SelectionObserver
  def onSelectionAdded(selection, entity)
    entity
  end
end

observer.onSelectionRemoved(selection, entity) ⇒ nil

Called when a single entity is removed from the selection.

Parameters:

  • selection (ModraUp::Selection)
  • entity (ModraUp::Entity)

Returns:

  • (nil)

Examples:

class MySel < ModraUp::SelectionObserver
  def onSelectionRemoved(selection, entity)
    entity
  end
end

observer.onSelectedRemoved(selection, entity) ⇒ nil

This alias, which is misspelled, is also called by SketchUp in addition to onSelectionRemoved. The host also dispatches this.

Parameters:

  • selection (ModraUp::Selection)
  • entity (ModraUp::Entity)

Returns:

  • (nil)

Examples:

class MySel < ModraUp::SelectionObserver
  def onSelectedRemoved(selection, entity)
    entity
  end
end

observer.onSelectionCleared(selection) ⇒ nil

Called when the selection set is cleared.

Parameters:

  • selection (ModraUp::Selection)

Returns:

  • (nil)

Examples:

class MySel < ModraUp::SelectionObserver
  def onSelectionCleared(selection)
    selection.empty?
  end
end