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

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

Field Detail

SC.SelectionSet.EMPTY
Default frozen empty selection set
isSelectionSet Boolean
Walk like a duck.

Instance Method Detail

add(source, start, length)

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
addObject(object)

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
addObjects(objects)

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
clear()
Clears the set. Removes all IndexSets from the object
Returns:
SC.SelectionSet
constrain(source)

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
contains(source, start, length)
Returns YES if the selection contains the named index, range of indexes.
Parameters:
source Object
source object for range
start Number
index, start of range, range object, or indexSet
length Number
optional range length
Returns:
Boolean
containsObject(object)

Returns YES if the selection contains the passed object. This will search selected ranges in all source objects.

Parameters:
object Object
the object to search for
Returns:
Boolean
copy()
Clones the set into a new set.
Returns:
SC.SelectionSet
forEach(callback, target)

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
indexSetForSource(source)

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
intersects(source, start, length)

Returns YES if the index set contains any of the passed indexes. You can pass a single index, a range or an index set.

Parameters:
source Object
source object for range
start Number
index, range, or IndexSet
length Number
optional range length
Returns:
Boolean
isEqual(obj)

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.

Parameters:
obj Object
another object.
Returns:
Boolean
length()
Total number of indexes in the selection set
remove(source, start, length)

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
removeObject(object)

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
removeObjects(object)

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
sources()

A set of all the source objects used in the selection set. This property changes automatically as you add or remove index sets.

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 08 2015 10:02:21 GMT-0600 (CST)