descala
Topic Author
Posts: 15
Joined: 19 Sep 2013, 20:11

GUI hit testing

13 Jan 2014, 23:42

Hi,

Is there any way to test whether a mouse click has been handled by a Noesis widget? I'm using C++ w/ OgreBindings.

Thanks.
 
User avatar
jsantos
Site Admin
Posts: 2900
Joined: 20 Jan 2012, 17:18
Contact:

Re: GUI hit testing

14 Jan 2014, 01:11

Do you want this to know if an input event must be sent to your 3d scene? We use HitTest() in our integration tutorial for this purpose:
static bool captured = false;

switch (uMsg)
{
    case WM_MOUSEMOVE:
    {
        if (gXamlRenderer != 0)
        {
            gXamlRenderer->MouseMove(LOWORD(lParam), HIWORD(lParam));
        }
        break;
    }
    case WM_LBUTTONDOWN:
    {
        if (gXamlRenderer != 0)
        {
            gXamlRenderer->MouseButtonDown(LOWORD(lParam), HIWORD(lParam), MouseButton_Left);

            if (VisualTreeHelper::HitTest(gXamlRenderer->GetContent(), Point(LOWORD(lParam), 
                HIWORD(lParam))).visualHit != 0)
            {
                captured = true;
            }
        }
        break;
    }
    case WM_LBUTTONUP:
    {
        if (gXamlRenderer != 0)
        {
            gXamlRenderer->MouseButtonUp(LOWORD(lParam), HIWORD(lParam), MouseButton_Left);
            captured = false;
        }
        break;
    }
}

if (!captured)
{
    g_Camera.HandleMessages( hWnd, uMsg, wParam, lParam );
    g_MCamera.HandleMessages( hWnd, uMsg, wParam, lParam );
    g_LCamera.HandleMessages( hWnd, uMsg, wParam, lParam );
}
Is this what you want?
 
descala
Topic Author
Posts: 15
Joined: 19 Sep 2013, 20:11

Re: GUI hit testing

16 Jan 2014, 21:56

Yes, that did it -- thanks!

Who is online

Users browsing this forum: No registered users and 1 guest