Skip to content

Support "Auto Move To Next Item" in ListView #1962

@tig

Description

@tig

ListView supports multi-select; SPACE toggles (@tznind I don't see a sample of TableView demonstrating multi-select).

In Out-ConsoleGridView a user has requested that when in multi-select mode (-OutputMode Multiple) pressing SPACE to select will toggle the item and move to the next row: PowerShell/ConsoleGuiTools#148

I don't see how to implement this in a generic/extensible way.

Ideally, I'd be able to (in Out-ConsoleGridView) define a new Command be added named ToggleCheckedWithKey:

...
            if (!_applicationData.MoveToNextOnSelect)
            {
                var cmd = new Command();
                _listView.AddCommand(cmd, () => { if (_listView.MarkUnmarkRow ()) return _listView.MoveDown (); else return false;  });
                _listView.AddKeyBinding(Key.Space, cmd);
            }

            win.Add(_listView);
...

But Command is not public, so this won't work.

We could modify ListView:

// change this:
			AddCommand (Command.ToggleChecked, () => MarkUnmarkRow ());

// to this:

			AddCommand (Command.ToggleChecked, () => {
				if (MarkUnmarkRow ()) {
					if (_moveNextOnToggleWithKey) {
						return MoveDown ();
					}
					return true;
				} else {
					return false;
				}
			});

But this means that if Command.ToggleChecked is invoked in a way OTHER than the SPACE key the MoveDown will happen, which is not what we want. Also, we have all this Command and KeyBinding functionality, and it seems crazy to have to add yet-another-option to ListView.

What are the best ideas for addressing this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions