Canvas PointerPressed event GetCurrentPoint throws exception [SOLVED]

Please report bugs here. If you are unsure whether something is a bug or an expected behavior, please post it on the "Technical Support" forum instead, and wait for a moderator to handle/move the post.
binaryfish
Posts: 11
Joined: Fri Oct 23, 2015 3:08 am

Canvas PointerPressed event GetCurrentPoint throws exception [SOLVED]

Postby binaryfish » Sat Oct 31, 2015 2:38 am

I have a Canvas control (CnvGrid). I then capture the PointerPressed event of the Canvas control. When I click on the canvas the PointerPressed event is raised. However I get the error:

An unhandled exception of type 'System.NullReferenceException' occurred in CSharpXamlForHtml5.dll
Object reference not set to an instance of an object.

Below is the code:

Code: Select all

private void CnvGrid_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
   var pos = e.GetCurrentPoint(CnvGrid);
}
       


If I replace CnvGrid with this so line becomes e.GetCurentPoint(this) same problem.

Is this a bug?

Gavin

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: Canvas PointerPressed event GetCurrentPoint throws exception

Postby JS-Support @Userware » Sun Nov 01, 2015 3:31 am

Hi Gavin,

Thanks for reporting this issue.

Yes, it is a bug. We have been able to successfully reproduce it.

It will be fixed in the very next build, which is expected in the next couple of weeks.

In the meantime, please use the following code to work around the issue:

Code: Select all

            // Get the absolute pointer coordinates:
            PointerPoint absolutePosition = e.GetCurrentPoint(null);

            // Get the opposite of the absolute position of the Canvas:
            GeneralTransform generalTransform = Window.Current.Content.TransformToVisual(CnvGrid);

            // Get the pointer coordinates relative to Canvas:
            Point relativePosition = generalTransform.TransformPoint(absolutePosition.Position);


Regards,
JS-Support

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: Canvas PointerPressed event GetCurrentPoint throws exception

Postby JS-Support @Userware » Tue Dec 22, 2015 11:30 am

Hi,

The issue was fixed in C#/XAML for HTML5 Beta 6, which can be downloaded from:

http://forums.cshtml5.com/viewforum.php?f=6

Thank you.
Regards,
JS-Support


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 34 guests

 

 

cron