Skip to content

GroupSortInteractionView

Overview

This doc assumes you have read the doc in GroupSelectModel. Read that first as it explains the "group select interaction" more generally.

This type adds sorting on top of the GroupSelectView in the interaction for (keyboard).

@author Michael Kauzmann (PhET Interactive Simulations) @author Marla Schulz (PhET Interactive Simulations)

Class GroupSortInteractionView

import { GroupSortInteractionView } from 'scenerystack/scenery-phet';

Constructor

new GroupSortInteractionView( model : GroupSelectModel<ItemModel>, primaryFocusedNode : Node, providedOptions : GroupSortInteractionViewOptions<ItemModel, ItemNode> )

Instance Methods

dispose()

Static Methods

create( model : GroupSelectModel<ItemModel>, primaryFocusedNode : Node, providedOptions : GroupSortInteractionViewOptions<ItemModel, ItemNode> ) : GroupSortInteractionView<ItemModel, ItemNode>

Creator factory, similar to PhetioObject.create(). This is most useful if you don't need to keep the instance of your GroupSortInteractionView.

Type GroupSortInteractionViewOptions

import type { GroupSortInteractionViewOptions } from 'scenerystack/scenery-phet';
  • getNextSelectedGroupItem: ( delta: number, currentlySelectedGroupItem: ItemModel ) => ItemModel
    Given the delta (difference from current value to new value), return the corresponding next group item model to be selected.
  • sortingRangeProperty: TReadOnlyProperty<Range>
    The available range for sorting. This is the acceptable range for the valueProperty of ItemModel (see model.getGroupItemValue()).
  • sortingRangeListener?: ( range: Range ) => void
  • sortGroupItem: ( groupItem: ItemModel, newValue: number ) => void
    Do the sort operation, allowing for custom actions, must be implemented by all implementations, but likely just should default to updating the "valueProperty" of the selected group item to the new value that is provided.
  • onSort?: ( groupItem: ItemModel, oldValue: number ) => void
    Callback called after a group item is sorted. Note that sorting may not have changed its value (like if at the boundary trying to move past the range).
  • numberKeyMapper?: ( ( pressedKeys: string ) => ( number | null ) ) | null
    If provided, listen to the number keys as well to sort the selected group item. Provide the value that the number key maps to. A direct value, not a delta. If the function returns null, then no action takes place for the input. If the option is set to null, then number keys will not be listened to for this interaction.
  • sortStep?: number
    The value-change delta step size when selecting/sorting the group items.
  • pageSortStep?: number
  • shiftSortStep?: number
  • & GroupSelectViewOptions<ItemModel, ItemNode>

Source Code

See the source for GroupSortInteractionView.ts in the scenery-phet repository.