# SelectionNodeBase

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/selection/struct-selectionnodebase/

**struct** · [`ferroui-controls`](/docs/0.5.0/api/ferroui-controls/) · v0.5.0

```rust
struct SelectionNodeBase<T: PropertyValue>
```

Base class for selection models.

`T` is the type of the element being selected.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L76)

## Members

- [`new`](#function-new)
- [`source`](#function-source)
- [`set_source`](#function-set_source)
- [`items_view`](#function-items_view)
- [`set_items_view`](#function-set_items_view)
- [`ranges_enabled`](#function-ranges_enabled)
- [`set_ranges_enabled`](#function-set_ranges_enabled)
- [`on_source_collection_change_started`](#function-on_source_collection_change_started)
- [`on_source_collection_changed`](#function-on_source_collection_changed)
- [`on_source_collection_change_finished`](#function-on_source_collection_change_finished)
- [`on_indexes_changed`](#function-on_indexes_changed)
- [`on_selection_removed`](#function-on_selection_removed)
- [`commit_select`](#function-commit_select)
- [`commit_deselect`](#function-commit_deselect)
- [`on_items_added`](#function-on_items_added)
- [`on_items_removed`](#function-on_items_removed)
- [`is_valid_collection_change`](#function-is_valid_collection_change)

<a id="function-new"></a>

### new

```rust
fn new(derived: Weak<dyn SelectionNodeBaseImpl<T>>) -> Self
```

Creates the base state of the object deriving from it; `derived`
receives the virtual calls.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L88)

<a id="function-source"></a>

### source

```rust
fn source(self: &Self) -> Option<ItemsSource>
```

Gets the source collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L104)

<a id="function-set_source"></a>

### set_source

```rust
fn set_source(self: &Self, value: Option<ItemsSource>)
```

Sets the source collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L109)

<a id="function-items_view"></a>

### items_view

```rust
fn items_view(self: &Self) -> Option<ItemsSourceViewOf<T>>
```

Gets a view of the `source`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L152)

<a id="function-set_items_view"></a>

### set_items_view

```rust
fn set_items_view(self: &Self, value: Option<ItemsSourceViewOf<T>>)
```

Sets the view of the source.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L157)

<a id="function-ranges_enabled"></a>

### ranges_enabled

```rust
fn ranges_enabled(self: &Self) -> bool
```

Gets a value indicating whether range selection is currently enabled
for the selection node.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L163)

<a id="function-set_ranges_enabled"></a>

### set_ranges_enabled

```rust
fn set_ranges_enabled(self: &Self, value: bool)
```

Sets a value indicating whether range selection is currently enabled
for the selection node.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L169)

<a id="function-on_source_collection_change_started"></a>

### on_source_collection_change_started

```rust
fn on_source_collection_change_started(self: &Self)
```

Called when the source collection starts changing.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L190)

<a id="function-on_source_collection_changed"></a>

### on_source_collection_changed

```rust
fn on_source_collection_changed(self: &Self, e: &ItemsChangedEventArgs<'_>)
```

Called when the `source` collection changes.

The implementation here calls `on_items_added` and
`on_items_removed` in order to calculate how the collection change
affects the currently selected items. It then calls
`on_indexes_changed` and `on_selection_removed` if necessary,
according to the `CollectionChangeState` returned by those methods.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L199)

<a id="function-on_source_collection_change_finished"></a>

### on_source_collection_change_finished

```rust
fn on_source_collection_change_finished(self: &Self)
```

Called when the source collection has finished changing, and all
collection changed handlers have run.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L264)

<a id="function-on_indexes_changed"></a>

### on_indexes_changed

```rust
fn on_indexes_changed(self: &Self, _shift_index: i32, _shift_delta: i32)
```

Called by the handling of a collection change, detailing the indexes
changed by the collection changing.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L268)

<a id="function-on_selection_removed"></a>

### on_selection_removed

```rust
fn on_selection_removed(self: &Self, _index: i32, _count: i32, _deselected_items: Vec<Option<T>>)
```

Called by the handling of a collection change, detailing the items
removed by a collection change.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L272)

<a id="function-commit_select"></a>

### commit_select

```rust
fn commit_select(self: &Self, begin: i32, end: i32) -> i32
```

If ranges are enabled, adds the specified inclusive range to the
selection. Returns the number of items selected.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L276)

<a id="function-commit_deselect"></a>

### commit_deselect

```rust
fn commit_deselect(self: &Self, begin: i32, end: i32) -> i32
```

If ranges are enabled, removes the specified inclusive range from
the selection. Returns the number of items deselected.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L288)

<a id="function-on_items_added"></a>

### on_items_added

```rust
fn on_items_added(self: &Self, index: i32, items: ItemsView<'_>) -> CollectionChangeState<T>
```

Called by the handling of a collection change when items are added
to the source collection.

The implementation here adjusts the selected ranges, assigning new
indexes.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L303)

<a id="function-on_items_removed"></a>

### on_items_removed

```rust
fn on_items_removed(self: &Self, index: i32, items: ItemsView<'_>) -> CollectionChangeState<T>
```

Called by the handling of a collection change when items are removed
from the source collection.

The implementation here adjusts the selected ranges, assigning new
indexes.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L347)

<a id="function-is_valid_collection_change"></a>

### is_valid_collection_change

```rust
fn is_valid_collection_change(self: &Self, e: &ItemsChangedEventArgs<'_>) -> bool
```

Whether a collection change can be applied to the selection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/selection/selection_node_base.rs#L385)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
