Skip to content

Commit

Permalink
Fix CascadeInputTransparent (dotnet#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
myroot committed Aug 25, 2022
1 parent 20920c1 commit 6d7e27d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/Controls/src/Core/HandlerImpl/Layout/Layout.Tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ public partial class Layout
{
public static void MapInputTransparent(LayoutHandler handler, Layout layout)
{
if (handler.PlatformView == null)
return;

if (layout.CascadeInputTransparent)
{
handler.PlatformView?.UpdateInputTransparent(handler, layout);
// Sensitive property on NUI View was false, disabled all touch event including children
handler.PlatformView.Sensitive = !layout.InputTransparent;
handler.PlatformView.InputTransparent = false;
}
else
{
// TODO. need to fix
// If CascadeInputTransparent is true, child should be got an event
// But, in NUI, if Container Sensitive was false, children also can't get an event
// So, We can't set Sensitive to false, and we should pass through an event into below view
// To pass through an event, on LayoutHandler.tizen I will ovrride OnHitTest method, and returning false when InputTransparent was true
// InputTransparent property on LayoutViewGroup was false,
// Only LayoutViewGroup event was disabled but children are allowed
handler.PlatformView.InputTransparent = layout.InputTransparent;
handler.PlatformView.Sensitive = true;
}
layout.UpdateDescendantInputTransparent();
}
}
}
8 changes: 8 additions & 0 deletions src/Core/src/Platform/Tizen/LayoutViewGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Rect = Microsoft.Maui.Graphics.Rect;
using Size = Microsoft.Maui.Graphics.Size;
using TSize = Tizen.UIExtensions.Common.Size;
using TTouch = Tizen.NUI.Touch;

namespace Microsoft.Maui.Platform
{
Expand All @@ -26,6 +27,13 @@ public TSize Measure(double availableWidth, double availableHeight)
return CrossPlatformMeasure?.Invoke(availableWidth.ToScaledDP(), availableHeight.ToScaledDP()).ToPixel() ?? new TSize(0, 0);
}

public bool InputTransparent { get; set; } = false;

protected override bool HitTest(TTouch touch)
{
return !InputTransparent;
}

void OnLayoutUpdated(object? sender, LayoutEventArgs e)
{
var platformGeometry = this.GetBounds().ToDP();
Expand Down

0 comments on commit 6d7e27d

Please sign in to comment.