Skip to content

Commit 5a84644

Browse files
committed
Delete key does discard/delete
1 parent 13a8bee commit 5a84644

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

ImageMap4/Controls/MapList.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
mc:Ignorable="d"
1010
d:DesignHeight="450"
1111
d:DesignWidth="800"
12-
Focusable="True">
12+
Focusable="True"
13+
MouseDown="List_MouseDown">
1314
<UserControl.InputBindings>
1415
<KeyBinding Modifiers="Ctrl"
1516
Key="A"

ImageMap4/Controls/MapList.xaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public MapList()
6060
private Selectable<Map>? LastClicked;
6161
private void Map_MouseDown(object sender, MouseButtonEventArgs e)
6262
{
63+
this.Focus();
6364
var map = (Selectable<Map>)((FrameworkElement)sender).DataContext;
6465
if (e.RightButton == MouseButtonState.Pressed)
6566
{
@@ -89,6 +90,11 @@ private void Map_MouseDown(object sender, MouseButtonEventArgs e)
8990
}
9091
LastClicked = map;
9192
}
93+
94+
private void List_MouseDown(object sender, MouseButtonEventArgs e)
95+
{
96+
this.Focus();
97+
}
9298
}
9399

94100
public class Selectable<T> : ObservableObject

ImageMap4/MainWindow.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
<KeyBinding Modifiers="Ctrl+Shift"
2626
Key="Z"
2727
Command="{Binding RedoCommand}" />
28+
<KeyBinding Key="Delete"
29+
Command="{Binding DeleteCommand, RelativeSource={RelativeSource AncestorType=Window}}" />
2830
</Window.InputBindings>
2931
<Window.Resources>
3032
<ResourceDictionary>
@@ -501,7 +503,8 @@
501503
</Button>
502504
</StackPanel>
503505
</StackPanel>
504-
<local:MapList Grid.Column="1"
506+
<local:MapList x:Name="ExistingList"
507+
Grid.Column="1"
505508
Grid.Row="1"
506509
DataContext="{Binding ExistingMapsView}"
507510
MapMenu="{StaticResource ExistingMenu}">

ImageMap4/MainWindow.xaml.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public partial class MainWindow : Window, IDropTarget
2929
{
3030
private MainViewModel ViewModel => (MainViewModel)this.DataContext;
3131
public ICommand PasteCommand { get; }
32+
public ICommand DeleteCommand { get; }
3233
public ICommand OpenWorldFolderCommand { get; }
3334
public ICommand OpenMapFileCommand { get; }
3435
public ICommand ChangeIDCommand { get; }
@@ -101,6 +102,13 @@ public MainWindow()
101102
ImageWindow.Activate();
102103
}
103104
});
105+
DeleteCommand = new RelayCommand(() =>
106+
{
107+
if (ImportList.IsFocused)
108+
ViewModel.DiscardCommand.Execute(ViewModel.ImportingMaps);
109+
else if (ExistingList.IsFocused)
110+
ViewModel.DeleteCommand.Execute(ViewModel.ExistingMaps);
111+
});
104112
InitializeComponent();
105113
}
106114

0 commit comments

Comments
 (0)