Hit Testing with ImGearARTText

Modified on Wed, Feb 19 at 3:52 PM

Issue

When writing a hit test (artGUI.Page.HitTest(igPoint, Viewer, Viewer.Display, igGraphics, 0, 0)) for a bounding box of an ImGearARTText, you may encounter an issue where the hit test only passes when clicking directly on the text rather than anywhere within the white space of the box. 


Cause

This behavior is often due to using the wrong coordinate space for the hit test. 


Solution

Improve hit test accuracy by converting mouse/client coordinates to image/page coordinates using ImageGearARTPage.ConvertCoordinates.  This ensures that the hit test is performed using coordinates relative to the image itself, rather than the text.


Code Example:

public ImGearPoint TransformToDocumentCoordinates(Point screenPoint, ImGearPageView pageView)
{
    ImGearPoint[] locations = new ImGearPoint[] {
        new ImGearPoint(screenPoint.X, screenPoint.Y)
    };
    pageView.Display.ConvertCoordinates(pageView, ImGearCoordConvModes.DEVICE_TO_IMAGE, locations);
    return locations[0];
}



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article