From 70f3ba800ef49951750e14d9931c9a20e62c2810 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Mon, 23 Jul 2018 15:00:54 -0400 Subject: [PATCH 1/4] Added more linux keys & added VS code config to .gitignore --- .gitignore | 5 +++++ src/Gtk/Avalonia.Gtk3/KeyTransform.cs | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index 583a2b8a2b..32acee4c90 100644 --- a/.gitignore +++ b/.gitignore @@ -165,6 +165,11 @@ $RECYCLE.BIN/ ################# .idea +################# +## VS Code +################# +.vscode/ + ################# ## Cake ################# diff --git a/src/Gtk/Avalonia.Gtk3/KeyTransform.cs b/src/Gtk/Avalonia.Gtk3/KeyTransform.cs index 5a34db2e04..69c5a1bf5f 100644 --- a/src/Gtk/Avalonia.Gtk3/KeyTransform.cs +++ b/src/Gtk/Avalonia.Gtk3/KeyTransform.cs @@ -33,17 +33,24 @@ namespace Avalonia.Gtk.Common { GdkKey.Prior, Key.Prior }, //{ GdkKey.?, Key.PageDown } { GdkKey.End, Key.End }, + { GdkKey.KP_End, Key.End }, { GdkKey.Home, Key.Home }, + { GdkKey.KP_Home, Key.Home }, { GdkKey.Left, Key.Left }, + { GdkKey.KP_Left, Key.Left }, { GdkKey.Up, Key.Up }, + { GdkKey.KP_Up, Key.Up }, { GdkKey.Right, Key.Right }, + { GdkKey.KP_Right, Key.Right }, { GdkKey.Down, Key.Down }, + { GdkKey.KP_Down, Key.Down }, { GdkKey.Select, Key.Select }, { GdkKey.Print, Key.Print }, { GdkKey.Execute, Key.Execute }, //{ GdkKey.?, Key.Snapshot } { GdkKey.Insert, Key.Insert }, { GdkKey.Delete, Key.Delete }, + { GdkKey.KP_Delete, Key.Delete }, { GdkKey.Help, Key.Help }, //{ GdkKey.?, Key.D0 } //{ GdkKey.?, Key.D1 } From cdf8d1f8b4810c86a2eaa56ade3a66dedd8efff5 Mon Sep 17 00:00:00 2001 From: wojciech krysiak Date: Mon, 23 Jul 2018 21:09:40 +0200 Subject: [PATCH 2/4] Fix For incorrect handling of NotifyCollectionChangedAction.Reset from IReactiveDerivedList<> --- src/Avalonia.Controls/Primitives/SelectingItemsControl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs index eb3fbde8f2..c8425a0f80 100644 --- a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs +++ b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs @@ -376,7 +376,7 @@ namespace Avalonia.Controls.Primitives break; case NotifyCollectionChangedAction.Reset: - SelectedIndex = IndexOf(e.NewItems, SelectedItem); + SelectedIndex = IndexOf(Items, SelectedItem); break; } } From 03e859445113e8f2b3ed34383a893cb19ecf517e Mon Sep 17 00:00:00 2001 From: wojciech krysiak Date: Mon, 23 Jul 2018 22:32:13 +0200 Subject: [PATCH 3/4] Bug reproduction unit test --- .../Primitives/SelectingItemsControlTests.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs b/tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs index c7a3465ac4..14e1b15ebc 100644 --- a/tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs +++ b/tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Collections.Specialized; using System.Linq; using Avalonia.Collections; using Avalonia.Controls.Presenters; @@ -13,6 +14,7 @@ using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.Markup.Data; using Avalonia.UnitTests; +using Moq; using Xunit; namespace Avalonia.Controls.UnitTests.Primitives @@ -686,6 +688,26 @@ namespace Avalonia.Controls.UnitTests.Primitives Assert.Null(KeyboardNavigation.GetTabOnceActiveElement((InputElement)panel)); } + [Fact] + public void Resetting_Items_Collection_Should_Retain_Selection() + { + var itemsMock = new Mock>(); + var itemsMockAsINCC = itemsMock.As(); + + itemsMock.Object.AddRange(new[] { "Foo", "Bar", "Baz" }); + var target = new SelectingItemsControl + { + Items = itemsMock.Object + }; + + target.SelectedIndex = 1; + + itemsMockAsINCC.Raise(e => e.CollectionChanged += null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); + + Assert.True(target.SelectedIndex == 1); + } + + private FuncControlTemplate Template() { return new FuncControlTemplate(control => From 23fdfe51df8ddb4f8d46203db7be7207edb431d2 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 25 Jul 2018 21:35:44 +0100 Subject: [PATCH 4/4] fix bug that was preventing user from cancelling window close. --- src/Avalonia.Controls/Window.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index d1a023c42c..7e1d8f18f0 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -302,17 +302,23 @@ namespace Avalonia.Controls internal void Close(bool ignoreCancel) { + bool close = true; + try { if (!ignoreCancel && HandleClosing()) { + close = false; return; } } finally { - PlatformImpl?.Dispose(); - HandleClosed(); + if (close) + { + PlatformImpl?.Dispose(); + HandleClosed(); + } } }