Class: SC.SelectionSet
Extends
SC.Copyable, SC.Enumerable, SC.Freezable, SC.Object.
A SelectionSet contains a set of objects that represent the current selection. You can select objects by either adding them to the set directly or indirectly by selecting a range of indexes on a source object.
Defined in: selection_set.js
- Since:
- SproutCore 1.0
Field Summary
- SC.SelectionSet.EMPTY
- isSelectionSet
- Fields borrowed from SC.Object:
- concatenatedProperties, isDestroyed, isObject, nextProperty, object, property, target, toInvalidate
- Fields borrowed from SC.Observable:
- isObservable
- Fields borrowed from SC.Enumerable:
- isEnumerable
- Fields borrowed from SC.Freezable:
- isFreezable, isFrozen
- Fields borrowed from SC.Copyable:
- isCopyable
Instance Methods
- add(source, start, length)
- addObject(object)
- addObjects(objects)
- clear()
- constrain(source)
- contains(source, start, length)
- containsObject(object)
- copy()
- forEach(callback, target)
- indexSetForSource(source)
- intersects(source, start, length)
- isEqual(obj)
- length()
- remove(source, start, length)
- removeObject(object)
- removeObjects(object)
- sources()
Field Detail
SC.SelectionSet.EMPTYInstance Method Detail
Add the passed index, range of indexSet
belonging to the passed source
object to the selection set.
The first parameter you pass must be the source array you are selecting from. The following parameters may be one of a start/length pair, a single index, a range object or an IndexSet. If some or all of the range you are selecting is already in the set, it will not be selected again.
You can also pass an SC.SelectionSet
to this method and all the selected
sets will be added from their instead.
- Parameters:
- source SC.Array
- source object or object to add.
- start Number
- index, start of range, range or IndexSet
- length Number
- length if passing start/length pair.
- Returns:
- SC.SelectionSet
- receiver
Adds the object to the selection set. Unlike adding an index set, the selection will actually track the object independent of its location in the array.
- Parameters:
- object Object
- Returns:
- SC.SelectionSet
- receiver
Adds objects in the passed enumerable to the selection set. Unlike adding an index set, the seleciton will actually track the object independent of its location the array.
- Parameters:
- objects SC.Enumerable
- Returns:
- SC.SelectionSet
- receiver
- Returns:
- SC.SelectionSet
Constrains the selection set to only objects found in the passed source object. This will remove any indexes selected in other sources, any indexes beyond the length of the content, and any objects not found in the set.
- Parameters:
- source Object
- the source to limit
- Returns:
- SC.SelectionSet
- receiver
Returns YES
if the selection contains the passed object. This will search
selected ranges in all source objects.
- Returns:
- SC.SelectionSet
Iterates over the selection, invoking your callback with each object. This will actually find the object referenced by each index in the selection, not just the index.
The callback must have the following signature:
function callback(object, index, source, indexSet) { ... }
If you pass a target, it will be used when the callback is called.
- Parameters:
- callback Function
- function to invoke.
- target Object
- optional content. otherwise uses window
- Returns:
- SC.SelectionSet
- receiver
Returns the index set for the passed source object or null if no items are seleted in the source.
- Parameters:
- source SC.Array
- the source object
- Returns:
- SC.IndexSet
- index set or null
Returns YES
if the index set contains any of the passed indexes. You
can pass a single index, a range or an index set.
Returns YES
if the passed index set or selection set contains the exact
same source objects and indexes as the receiver. If you pass any object
other than an IndexSet or SelectionSet, returns NO.
Removes the passed index, range of indexSet
belonging to the passed source
object from the selection set.
The first parameter you pass must be the source array you are selecting from. The following parameters may be one of a start/length pair, a single index, a range object or an IndexSet. If some or all of the range you are selecting is already in the set, it will not be selected again.
- Parameters:
- source SC.Array
- source object. must not be null
- start Number
- index, start of range, range or IndexSet
- length Number
- length if passing start/length pair.
- Returns:
- SC.SelectionSet
- receiver
Removes the object from the selection set. Note that if the selection set also selects a range of indexes that includes this object, it may still be in the selection set.
- Parameters:
- object Object
- Returns:
- SC.SelectionSet
- receiver
Removes the objects from the selection set. Note that if the selection set also selects a range of indexes that includes this object, it may still be in the selection set.
- Parameters:
- object Object
- Returns:
- SC.SelectionSet
- receiver
A set of all the source objects used in the selection set. This property changes automatically as you add or remove index sets.