Browse Source

hittest when button is pressed

pull/2001/head
Andrey Kunchev 8 years ago
parent
commit
ef158e3ec3
  1. 10
      src/Avalonia.Controls/Button.cs

10
src/Avalonia.Controls/Button.cs

@ -2,6 +2,7 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Linq;
using System.Windows.Input;
using Avalonia.Data;
using Avalonia.Input;
@ -251,8 +252,9 @@ namespace Avalonia.Controls
IsPressed = false;
e.Handled = true;
if (ClickMode == ClickMode.Release &&
(IsPointerOver || new Rect(Bounds.Size).Contains(e.GetPosition(this))))
var hittest = VisualRoot?.Renderer?.HitTest(e.GetPosition(VisualRoot), VisualRoot, null);
if (ClickMode == ClickMode.Release && hittest?.Any(v => v == this) == true)
{
OnClick();
}
@ -262,9 +264,9 @@ namespace Avalonia.Controls
protected override void UpdateDataValidation(AvaloniaProperty property, BindingNotification status)
{
base.UpdateDataValidation(property, status);
if(property == CommandProperty)
if (property == CommandProperty)
{
if(status?.ErrorType == BindingErrorType.Error)
if (status?.ErrorType == BindingErrorType.Error)
{
IsEnabled = false;
}

Loading…
Cancel
Save