Browse Source

Merge branch 'master' into datagrid_drag_treshold

pull/6780/head
Max Katz 5 years ago
committed by GitHub
parent
commit
f1a6dbc267
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      native/Avalonia.Native/src/OSX/window.mm
  2. 2
      src/Avalonia.Diagnostics/Diagnostics/Models/EventChainLink.cs
  3. 26
      src/Avalonia.Diagnostics/Diagnostics/ViewModels/EventTreeNode.cs
  4. 5
      src/Avalonia.Diagnostics/Diagnostics/ViewModels/FiredEvent.cs

4
native/Avalonia.Native/src/OSX/window.mm

@ -52,7 +52,6 @@ public:
[Window setBackingType:NSBackingStoreBuffered];
[Window setOpaque:false];
[Window setContentView: StandardContainer];
}
virtual HRESULT ObtainNSWindowHandle(void** ret) override
@ -125,6 +124,8 @@ public:
SetPosition(lastPositionSet);
UpdateStyle();
[Window setContentView: StandardContainer];
[Window setTitle:_lastTitle];
if(ShouldTakeFocusOnShow() && activate)
@ -323,6 +324,7 @@ public:
BaseEvents->Resized(AvnSize{x,y}, reason);
}
[StandardContainer setFrameSize:NSSize{x,y}];
[Window setContentSize:NSSize{x, y}];
}
@finally

2
src/Avalonia.Diagnostics/Diagnostics/Models/EventChainLink.cs

@ -29,7 +29,7 @@ namespace Avalonia.Diagnostics.Models
}
}
public bool Handled { get; }
public bool Handled { get; set; }
public RoutingStrategies Route { get; }
}

26
src/Avalonia.Diagnostics/Diagnostics/ViewModels/EventTreeNode.cs

@ -55,6 +55,8 @@ namespace Avalonia.Diagnostics.ViewModels
// FIXME: This leaks event handlers.
Event.AddClassHandler(typeof(object), HandleEvent, allRoutes, handledEventsToo: true);
Event.RouteFinished.Subscribe(HandleRouteFinished);
_isRegistered = true;
}
}
@ -92,6 +94,30 @@ namespace Avalonia.Diagnostics.ViewModels
else
handler();
}
private void HandleRouteFinished(RoutedEventArgs e)
{
if (!_isRegistered || IsEnabled == false)
return;
if (e.Source is IVisual v && BelongsToDevTool(v))
return;
var s = e.Source;
var handled = e.Handled;
var route = e.Route;
void handler()
{
if (_currentEvent != null && handled)
{
var linkIndex = _currentEvent.EventChain.Count - 1;
var link = _currentEvent.EventChain[linkIndex];
link.Handled = true;
_currentEvent.HandledBy = link;
}
}
}
private static bool BelongsToDevTool(IVisual v)
{

5
src/Avalonia.Diagnostics/Diagnostics/ViewModels/FiredEvent.cs

@ -63,8 +63,8 @@ namespace Avalonia.Diagnostics.ViewModels
{
if (EventChain.Count > 0)
{
var prevLink = EventChain[EventChain.Count-1];
var prevLink = EventChain[EventChain.Count - 1];
if (prevLink.Route != link.Route)
{
link.BeginsNewRoute = true;
@ -72,6 +72,7 @@ namespace Avalonia.Diagnostics.ViewModels
}
EventChain.Add(link);
if (HandledBy == null && link.Handled)
HandledBy = link;
}

Loading…
Cancel
Save