Skip to content

Pointer events has wrong location when in a ViewBox on Android #2257

Closed

Description

@dr1rrb

Current behavior

Pointer location are not valid

Expected behavior

As UWP

How to reproduce it (as minimally and precisely as possible)

<Grid Background="#FF583793">
        <Viewbox  Stretch="Uniform" StretchDirection="Both">
            <Canvas x:Name="mainCanvas" Height="800" Width="800" Background="#FFA0ACA5" Margin="50,50,50,50" PointerPressed="UIElement_OnPointerPressed">
                <TextBlock x:Name="tblInfos" Height="64" Canvas.Left="10" Canvas.Top="10" Text="TextBlock" TextWrapping="Wrap" Width="780" FontSize="20" FontWeight="Bold"/>
                <TextBlock x:Name="tblInfos2" Height="64" Canvas.Left="10" Canvas.Top="63" Text="TextBlock" TextWrapping="Wrap" Width="780" FontSize="20" FontWeight="Bold"/>
                <Border x:Name="letter" BorderThickness="1" BorderBrush="Black" Height="200" Canvas.Left="50" Canvas.Top="300" Width="500" Background="#FF8D7E3B" HorizontalAlignment="Stretch"/>
            </Canvas>
        </Viewbox>

    </Grid>
        private void UIElement_OnPointerPressed(object sender, PointerRoutedEventArgs e)
        {
            var posCanvas = e.GetCurrentPoint(mainCanvas).Position;
            var posLetter = e.GetCurrentPoint(letter).Position;
            tblInfos.Text = $"canvas x:{posCanvas.X} y:{posCanvas.Y}";
            tblInfos2.Text = $"letter x:{posLetter.X} y:{posLetter.Y}";

        }

Environment

Nuget Package: Uno.UI
Package Version(s): 2.0
Affected platform(s):

  • [?] iOS
  • Android
  • WebAssembly
  • WebAssembly renderers for Xamarin.Forms
  • Windows
  • Build tasks
  • Solution Templates

Visual Studio: irrelevant
Relevant plugins: none

Anything else we need to know?

https://stackoverflow.com/questions/59027861/content-not-centered-in-viewbox-and-incorect-mouse-coord-in-viewbox

Activity

  1. added
    kind/bug
    platform/android 🤖
    triage/untriaged
    on Dec 4, 2019
  2. self-assigned this
    on Dec 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugplatform/android 🤖triage/untriaged

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions