|
|
|
@ -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) |
|
|
|
{ |
|
|
|
|