uno
uno copied to clipboard
We need to set a Background on panels (e.g. SKXamlCanvas) to get pointer / manipulation events
Current behavior
OnManipulationDelta is not fired for SkXamlCanvas on Anroid
Expected behavior
OnManipulationDelta should work as it does on UWP.
How to reproduce it (as minimally and precisely as possible)
Load the attached project in UWP and observe that manipulation event is fired for both Grid and SkXamlCanvas. Load Android project and observe that manipulation events only fire for Grid.
Environment
Nuget Package:
Uno.SkiaSharp.Views
Package Version(s):
1.68.0
Affected platform(s):
- [ ] iOS
- [x] Android
- [x] WebAssembly
- [ ] WebAssembly renderers for Xamarin.Forms
- [ ] Windows
- [ ] Build tasks
- [ ] Solution Templates
Visual Studio:
- [ ] 2017 (version: )
- [ ] 2019 (version: )
- [ ] for Mac (version: )
Relevant plugins:
- [ ] Resharper (version: )
Anything else we need to know?
******************************** Investigation result ********************************
It's the expected result for Panel
due to https://github.com/unoplatform/uno/blob/c76a2a36ef840213fd30d01c8d9d6aa71b824aa0/src/Uno.UI/UI/Xaml/Controls/Panel/Panel.cs#L187 and https://github.com/unoplatform/uno/blob/c76a2a36ef840213fd30d01c8d9d6aa71b824aa0/src/Uno.UI/UI/Xaml/Controls/Border/Border.cs#L310 but this is annoying for the SKXamlCanvas
as it's actually not really a panel ...
******************************** WORKAROUND ********************************
Set Background="Transparent"
This issue is related to https://github.com/unoplatform/uno/issues/1940
We can repro with 2.0.512-dev.3874
The issues is related with the hit testing detection, where a type inheriting directly from FrameworkElement
uses the default behavior of a transparent control cannot have manipulations set to it.
A possible workaround is to set a Background
property to something other than transparent. In the case of the SKXamlCanvas
, which is generally completely overridden by another color, that may be enough.
@peternary Do you need the Skia canvas to be partially transparent ?
@jeromelaban No, we do write a background color. Will set the Background property to a color as a workaround for now.
Isnt this fixed?
~~This might have been fixed by https://github.com/unoplatform/uno/pull/7571~~
Edit: It does not!
Ah, I think I just hit this as well, but not entirely sure as I'm not seeing things layout in my Canvas correctly, can follow-up later this week after tomorrow.
Hey @michael-hawker are you also using the SKXamlCanvas
? I found that it's now working as long as you set a non null
Background
on it. Did you try that yet?
Note: I just found that we do have an issue with background rendering on iOS with the SKXamlCanvas
(https://github.com/unoplatform/uno/issues/9337) you can use only a Transparent
background.
I honestly don't remember leaving that comment a few days ago, not sure if it was the exact same circumstance...
I know at that time I was validating our CanvasView component in WASM which was both not displaying things in the correct location, and also ignoring the Manipulation Delta events (or maybe they were received but couldn't be displayed because of the first problem).
As seen here at https://toolkitlabs.dev these boxes shouldn't be all on top of one another, and they should be draggable:
Well @michael-hawker I tried your sample, and it seems to be a binding issue. The ManipulationDelta
handler is being invoked and in that handler if I replace the SetBindingExpression
by a simple SetValue
I'm able to move the elements:
//cp.SetBindingExpressionValue(Canvas.LeftProperty, Canvas.GetLeft(cp) + e.Delta.Translation.X);
//cp.SetBindingExpressionValue(Canvas.TopProperty, Canvas.GetTop(cp) + e.Delta.Translation.Y);
cp.SetValue(Canvas.LeftProperty, Canvas.GetLeft(cp) + e.Delta.Translation.X);
cp.SetValue(Canvas.TopProperty, Canvas.GetTop(cp) + e.Delta.Translation.Y);
Has you are already doing the same kind of magic to set the original values of the attached Canvas.<Left|Top>
properties, it's most probably the same issue. Do you already have an issue for the layouting issue we can link to?
@dr1rrb interesting, so there might be an issue with the underlying binding code there in Uno WASM (as it works fine in UWP and WinAppSDK). Will have to investigate further. Don't have any other issues open yet.
@dr1rrb interesting, so there might be an issue with the underlying binding code there in Uno WASM (as it works fine in UWP and WinAppSDK). Will have to investigate further. Don't have any other issues open yet.
@michael-hawker I would not be surprised if Uno were having discrepancies in the way property vs. fields are declared, causing this line to fail silently when a binding is declared.
@jeromelaban thanks, yeah I suspect there's something going on there. We still need to update to the latest Uno version, so that's still the first step for us to check-out. We do the special redirect here in order to support the binding pass-through for the templating of how this system works for Canvas
.