Class CollectionNavigator
Navigates a collection of items using keystrokes. The keystrokes are used to build a search string.
The SearchString is used to find the next item in the collection that matches the search string
when GetNextMatchingItem(Int32, Char) is called.
If the user types keystrokes that can't be found in the collection, the search string is cleared and the next item is found that starts with the last keystroke.
If the user pauses keystrokes for a short time (see TypingDelay), the search string is cleared.
Inheritance
System.Object
CollectionNavigator
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Terminal.Gui
Assembly: Terminal.Gui.dll
Syntax
public class CollectionNavigator
Constructors
| Improve this Doc View SourceCollectionNavigator()
Constructs a new CollectionNavigator.
Declaration
public CollectionNavigator()
CollectionNavigator(IEnumerable<Object>)
Constructs a new CollectionNavigator for the given collection.
Declaration
public CollectionNavigator(IEnumerable<object> collection)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Object> | collection |
Properties
| Improve this Doc View SourceCollection
The collection of objects to search. System.Object.ToString() is used to search the collection.
Declaration
public IEnumerable<object> Collection { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Object> |
Comparer
The compararer function to use when searching the collection.
Declaration
public StringComparer Comparer { get; set; }
Property Value
Type | Description |
---|---|
System.StringComparer |
SearchString
Gets the current search string. This includes the set of keystrokes that have been pressed
since the last unsuccessful match or after TypingDelay) milliseconds. Useful for debugging.
Declaration
public string SearchString { get; }
Property Value
Type | Description |
---|---|
System.String |
TypingDelay
Gets or sets the number of milliseconds to delay before clearing the search string. The delay is
reset on each call to GetNextMatchingItem(Int32, Char). The default is 500ms.
Declaration
public int TypingDelay { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceGetNextMatchingItem(Int32, Char)
Gets the index of the next item in the collection that matches the current SearchString plus the provided character (typically
from a key press).
Declaration
public int GetNextMatchingItem(int currentIndex, char keyStruck)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | currentIndex | The index in the collection to start the search from. |
System.Char | keyStruck | The character of the key the user pressed. |
Returns
Type | Description |
---|---|
System.Int32 | The index of the item that matches what the user has typed. Returns langword_csharp_-1 if no item in the collection matched. |
IsCompatibleKey(KeyEvent)
Returns true if
kb
is a searchable key
(e.g. letters, numbers etc) that is valid to pass to to this
class for search filtering.
Declaration
public static bool IsCompatibleKey(KeyEvent kb)
Parameters
Type | Name | Description |
---|---|---|
KeyEvent | kb |
Returns
Type | Description |
---|---|
System.Boolean |
OnSearchStringChanged(CollectionNavigator.KeystrokeNavigatorEventArgs)
Invoked when the SearchString changes. Useful for debugging. Invokes the SearchStringChanged event.
Declaration
public virtual void OnSearchStringChanged(CollectionNavigator.KeystrokeNavigatorEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
CollectionNavigator.KeystrokeNavigatorEventArgs | e |
Events
| Improve this Doc View SourceSearchStringChanged
This event is invoked when SearchString changes. Useful for debugging.
Declaration
public event Action<CollectionNavigator.KeystrokeNavigatorEventArgs> SearchStringChanged
Event Type
Type | Description |
---|---|
System.Action<CollectionNavigator.KeystrokeNavigatorEventArgs> |