Irregular Hotspots RRS feed

  • Question

  • Guys

    Is it possible to have an irregular hotspot area in a windows store app

    I have building plans which I would like to touch a particular are and it then goes to a page dedicated to that area

    I used to do it for the web just wondering if i could do it in an app


    Friday, November 15, 2013 11:02 AM


All replies

  • It's possible, but not built in. You would need to implement the irregular clipping yourself. Two possibilities that come to mind are to hittest against a Path object or to create a bitmap with the hit area and check if the pixel at the touch point is turned on. Whatever you do, make sire the target isn't too finicky since fingers arent high precision devices. --Rob
    Friday, November 15, 2013 3:28 PM
  • hi rob

    ok I got the app how i want it I though I could get the coordinates using Windows.UI.Input.PointerPoint

    Problem I have is the image I am showing is 4 times bigger that the view and I use panning to scroll around the screen

    is there a way of getting the coordinates of where you click based on its point in the image?

    so for instance if i scroll to the bottom right the x cord is 5000 instead of 1378

    Hope i explained myself


    Saturday, November 16, 2013 11:42 PM
  • I have a game that is very similar in that it only shows part of the whole game on the screen at once.

    If you can save the top left hand side of the overscreen x,y then you can add the pointer x,y to those to get absolute coordinates.


    Saturday, November 16, 2013 11:47 PM
  • nigel

    That sounds ok but i use zoom as well

    when the image is loaded the image is shrunk so the whole image fits in the view I then pinch and zoom to blow it up and scroll horizontally to find the area i want. I then tap on the area i want

    surely if I added the coordinates then it would be different depending which scale I am at

    It at that point I need where the tap was in relation to the image so that I can do some code top go to a page specific to that part of the image


    Sunday, November 17, 2013 7:36 AM
  • Nigel

    The following seems to work

                 Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
                 Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(MainImage);
                 this.text1.Text = ptrPt.Position.ToString();

    it puts the position in a textblock

    problem is it is in the format "111.333,333.444"

    how do i get it into two variables say xcord and ycord so that I can then use a case statement to go to a specific page depending on location.

    I think it string.split but cant get my head around it


    Sunday, November 17, 2013 8:42 AM
  • sorry i keep answering my own question

    The following works

                Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
                Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(MainImage);
                string x = (ptrPt.Position.ToString());
                string[] cord = x.Split(new Char[] { ' ', ',',  '\t' });
                this.text1.Text = (ptrPt.Position.ToString());
                this.text2.Text = cord[0];
                this.text3.Text = cord[1];

    now I need to change cord[0] and cord[1] to mumbers and the check  if its in a range

    something like the VB code:

    if cord[0] > 500 AND cord[0] < 600 AND cord[1]>300 AND cord[1]<300 then

    \\do something

    End If

    Any Ideas


    Sunday, November 17, 2013 8:57 AM
  • Guys

    1 final thing

    as I am using the pointerpressed event to detect where on the screen i have touched

    the following gives me the coordinates relative to the image

    Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
                Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(MainImage);

    what i need is to put it in the tapped event but it throws errors

    the problem is it works fine as it but if i do a gesture (say pinch and zoom) over an area that is programmed to accept the input it goes to a page

    I want to go to the page only if i tap on that area not click or gesture on it

    How do i get the coordinates for the TappedRoutedEventArgs instead of the PointerRoutedEventArgs?


    Tuesday, November 19, 2013 12:13 AM
  • Wednesday, November 20, 2013 1:18 AM
  • thanks rob

    I put the code in the double tapped event so now i can pinch and zoom and swipe but only double tapping will run the code


    Wednesday, November 20, 2013 6:08 AM