Preserve selection on selected items, require control key to unselect
- Issue MatterHackers/MCCentral#3960 ListView selection behavior inconsistent with expectations
This commit is contained in:
parent
cfa013006a
commit
844c601f8a
1 changed files with 7 additions and 5 deletions
|
|
@ -168,8 +168,9 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
{
|
||||
if (this.IsSelectableContent)
|
||||
{
|
||||
// Existing selection only survives with ctrl->click
|
||||
if (!Keyboard.IsKeyDown(Keys.ControlKey))
|
||||
// Clear existing selection when item is not selected and control key is not press
|
||||
if (!this.IsSelected
|
||||
&& !Keyboard.IsKeyDown(Keys.ControlKey))
|
||||
{
|
||||
listViewItem.ListView?.SelectedItems.Clear();
|
||||
}
|
||||
|
|
@ -189,7 +190,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
if (this.IsSelectableContent
|
||||
&& !hitDragThreshold)
|
||||
{
|
||||
if (wasSelected)
|
||||
if (toggleSelection)
|
||||
{
|
||||
listViewItem.ListView?.SelectedItems.Remove(listViewItem);
|
||||
}
|
||||
|
|
@ -259,7 +260,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
|
||||
private bool hitDragThreshold = false;
|
||||
|
||||
private bool wasSelected = false;
|
||||
private bool toggleSelection = false;
|
||||
|
||||
public override void OnMouseDown(MouseEventArgs mouseEvent)
|
||||
{
|
||||
|
|
@ -267,7 +268,8 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
mouseDownAt = mouseEvent.Position;
|
||||
hitDragThreshold = false;
|
||||
|
||||
wasSelected = this.IsSelected;
|
||||
// Used to toggle selection on selected items - revised to require control key
|
||||
toggleSelection = this.IsSelected && Keyboard.IsKeyDown(Keys.ControlKey);
|
||||
|
||||
this.EnsureSelection();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue