Skip to content

Commit

Permalink
Merge pull request #18893 from unoplatform/mergify/bp/release/stable/…
Browse files Browse the repository at this point in the history
…5.5/pr-18873

fix: Fix HRI not being draggable (backport #18873)
  • Loading branch information
jeromelaban authored Nov 23, 2024
2 parents 62f1f40 + ceeb32c commit 47a0680
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/Uno.UI.Toolkit/Diagnostics/DiagnosticsOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,11 @@ protected override void OnVisibilityChanged(Visibility oldValue, Visibility newV
/// <inheritdoc />
protected override void OnApplyTemplate()
{
if (_anchor is not null)
if (_toolbar is not null)
{
//_anchor.Tapped -= OnAnchorTapped;
_anchor.ManipulationDelta -= OnAnchorManipulated;
_anchor.ManipulationCompleted -= OnAnchorManipulatedCompleted;
_toolbar.ManipulationDelta -= OnAnchorManipulated;
_toolbar.ManipulationCompleted -= OnAnchorManipulatedCompleted;
}
if (_notificationPresenter is not null)
{
Expand All @@ -377,12 +377,12 @@ protected override void OnApplyTemplate()
_anchor = GetTemplateChild(AnchorPartName) as UIElement;
_notificationPresenter = GetTemplateChild(NotificationPartName) as ContentPresenter;

if (_anchor is not null)
if (_toolbar is not null)
{
//_anchor.Tapped += OnAnchorTapped;
_anchor.ManipulationDelta += OnAnchorManipulated;
_anchor.ManipulationCompleted += OnAnchorManipulatedCompleted;
_anchor.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY | ManipulationModes.TranslateInertia;
_toolbar.ManipulationDelta += OnAnchorManipulated;
_toolbar.ManipulationCompleted += OnAnchorManipulatedCompleted;
_toolbar.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY | ManipulationModes.TranslateInertia;
RenderTransform = new TranslateTransform();
}
if (_notificationPresenter is not null)
Expand All @@ -399,9 +399,14 @@ protected override void OnApplyTemplate()
static void OnToolBarSizeChanged(object sender, SizeChangedEventArgs args)
{
// Patches pointer event dispatch on a 0x0 Canvas
if (sender is UIElement uie && uie.GetTemplatedParent() is DiagnosticsOverlay { TemplatedRoot: Canvas canvas })
if (sender is UIElement uie && uie.GetTemplatedParent() is DiagnosticsOverlay { TemplatedRoot: Canvas canvas } overlay)
{
canvas.Width = args.NewSize.Width;

#if __ANDROID__
// Required for Android to effectively update the ActualSize allowing the RenderTransformAdapter to accept to apply the transform.
overlay.DispatcherQueue.TryEnqueue(() => canvas.InvalidateMeasure());
#endif
}
}
#endif
Expand Down

0 comments on commit 47a0680

Please sign in to comment.