Browse Source
Merge branch 'master' into fixes/gpu-memory-spike-leak
pull/4554/head
danwalmsley
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
45 additions and
1 deletions
-
src/Avalonia.Controls/ContextMenu.cs
-
src/Windows/Avalonia.Win32/Win32Platform.cs
-
tests/Avalonia.Controls.UnitTests/ContextMenuTests.cs
|
|
|
@ -279,6 +279,11 @@ namespace Avalonia.Controls |
|
|
|
((ISetLogicalParent)_popup).SetParent(control); |
|
|
|
} |
|
|
|
|
|
|
|
if (PlacementTarget is null && _popup.PlacementTarget != control) |
|
|
|
{ |
|
|
|
_popup.PlacementTarget = control; |
|
|
|
} |
|
|
|
|
|
|
|
_popup.Child = this; |
|
|
|
IsOpen = true; |
|
|
|
_popup.IsOpen = true; |
|
|
|
|
|
|
|
@ -88,7 +88,7 @@ namespace Avalonia.Win32 |
|
|
|
.Bind<IPlatformSettings>().ToConstant(s_instance) |
|
|
|
.Bind<IPlatformThreadingInterface>().ToConstant(s_instance) |
|
|
|
.Bind<IRenderLoop>().ToConstant(new RenderLoop()) |
|
|
|
.Bind<IRenderTimer>().ToConstant(new DefaultRenderTimer(60)) |
|
|
|
.Bind<IRenderTimer>().ToConstant(new UiThreadRenderTimer(60)) |
|
|
|
.Bind<ISystemDialogImpl>().ToSingleton<SystemDialogImpl>() |
|
|
|
.Bind<IWindowingPlatform>().ToConstant(s_instance) |
|
|
|
.Bind<PlatformHotkeyConfiguration>().ToSingleton<PlatformHotkeyConfiguration>() |
|
|
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
using System; |
|
|
|
using Avalonia.Input; |
|
|
|
using Avalonia.LogicalTree; |
|
|
|
using Avalonia.Markup.Xaml; |
|
|
|
using Avalonia.Markup.Xaml.MarkupExtensions; |
|
|
|
using Avalonia.Platform; |
|
|
|
@ -132,6 +133,44 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
popupImpl.Verify(x => x.Show(), Times.Exactly(2)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Context_Menu_Can_Be_Shared_Between_Controls_Even_After_A_Control_Is_Removed_From_Visual_Tree() |
|
|
|
{ |
|
|
|
using (Application()) |
|
|
|
{ |
|
|
|
var sut = new ContextMenu(); |
|
|
|
var target1 = new Panel |
|
|
|
{ |
|
|
|
ContextMenu = sut |
|
|
|
}; |
|
|
|
|
|
|
|
var target2 = new Panel |
|
|
|
{ |
|
|
|
ContextMenu = sut |
|
|
|
}; |
|
|
|
|
|
|
|
var sp = new StackPanel { Children = { target1, target2 } }; |
|
|
|
var window = new Window { Content = sp }; |
|
|
|
|
|
|
|
window.ApplyTemplate(); |
|
|
|
window.Presenter.ApplyTemplate(); |
|
|
|
|
|
|
|
_mouse.Click(target1, MouseButton.Right); |
|
|
|
|
|
|
|
Assert.True(sut.IsOpen); |
|
|
|
|
|
|
|
_mouse.Click(target2, MouseButton.Left); |
|
|
|
|
|
|
|
Assert.False(sut.IsOpen); |
|
|
|
|
|
|
|
sp.Children.Remove(target1); |
|
|
|
|
|
|
|
_mouse.Click(target2, MouseButton.Right); |
|
|
|
|
|
|
|
Assert.True(sut.IsOpen); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Cancelling_Opening_Does_Not_Show_ContextMenu() |
|
|
|
|