Mouse Cursor Issues [SOLVED]

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

PhoenixAdept
Just popping in
Just popping in
Posts: 3
Joined: Wed Jun 13, 2007 22:36
Location: Austin, TX

Mouse Cursor Issues [SOLVED]

Postby PhoenixAdept » Tue Jun 19, 2007 14:42

Hi all,
I'm new to CEGUI but I've spent the last 2 days going through the wiki and I've come across a problem that I can't seem to figure out. The CEGUI Mouse cursor seems like it's being updated incorrectly. No matter which way I move the mouse, the cursor will always go down and to the right. The position is always added upon.

Here is my code:

Windows Loop:

Code: Select all

HRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
    case WM_MOUSEMOVE:
        {
            bool test = CEGUI::System::getSingleton().injectMouseMove((float)LOWORD(lParam) * .05f, (float)HIWORD(lParam)* .05f);
            if(!test)
                CEGUI::MouseCursor::getSingleton().setImage("TaharezLook", "MouseArrow");
        }
        break;
    case WM_LBUTTONDOWN:
        {
            CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);
        }
        break;
    case WM_LBUTTONUP:
        {
            CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);
        }
        break;
    case WM_KEYDOWN:
        {
            if(wParam == VK_ESCAPE)
                PostQuitMessage(0);
        }
        break;
    case WM_QUIT:
        DestroyWindow(hWnd);
        break;
    }

    return (HRESULT)DefWindowProc(hWnd, msg, wParam, lParam);
}


CEGUI Intialization

Code: Select all


    // Create a renderer
    mpGUI = new CEGUI::DirectX9Renderer(device, 512);
    mpGUI->setDisplaySize(Size(800, 600));
    new CEGUI::System(mpGUI);
    mSelected = false;
   

    CEGUI::DefaultResourceProvider* resources = static_cast<CEGUI::DefaultResourceProvider*>(CEGUI::System::getSingleton().getResourceProvider());

    resources->setResourceGroupDirectory("schemes", "./datafiles/schemes/");
    resources->setResourceGroupDirectory("imagesets","./datafiles/imagesets/");
    resources->setResourceGroupDirectory("fonts", "./datafiles/fonts/");
    resources->setResourceGroupDirectory("layouts","./datafiles/layouts/");
    resources->setResourceGroupDirectory("looknfeel","./datafiles/looknfeel/");

    CEGUI::Scheme::setDefaultResourceGroup("schemes");
    CEGUI::Imageset::setDefaultResourceGroup("imagesets");
    CEGUI::Font::setDefaultResourceGroup("fonts");
    CEGUI::WindowManager::setDefaultResourceGroup("layouts");
    CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeel");

    // Logging
    CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);

    // Load the Imageset
    Imageset* pImages = ImagesetManager::getSingleton().createImageset("TaharezLook.imageset");

    // Set the Mouse cursor
    CEGUI::System::getSingleton().setDefaultMouseCursor(&pImages->getImage("MouseArrow"));
   
    CEGUI::MouseCursor::getSingleton().setConstraintArea(NULL );
   

    // Load the Font
    FontManager::getSingleton().createFont("Commonwealth-10.font");

    // Widgets
    WidgetLookManager::getSingleton().parseLookNFeelSpecification("TaharezLook.looknfeel");

    //Scheme
    SchemeManager::getSingleton().loadScheme("TaharezLookWidgets.scheme");
    // Done Loading GUI Assets

    // GUI Creation time.
    // Window Manager
    WindowManager& wndManager = WindowManager::getSingleton();
   
    // Create an invisible window for all other windows to attach to
    DefaultWindow* root = (DefaultWindow*)wndManager.createWindow("DefaultWindow", "Root");
   
    // Set this as our base window(they call it a sheet).
    CEGUI::System::getSingleton().setGUISheet(root);
    root->setMaxSize(UVector2(CEGUI::UDim(0, 800), CEGUI::UDim(0, 600) ) );
    root->setSize(UVector2(CEGUI::UDim(0, 800), CEGUI::UDim(0, 600) ) );

   
    // Create a Window with just a title bar
    FrameWindow* frameWnd = (FrameWindow*)wndManager.createWindow("TaharezLook/FrameWindow", "GUITest");

    // Attach to our "sheet"/base window
    root->addChildWindow(frameWnd);

    // Change our size and position. Size and position are relative to the parent's size and position.
    // i.e. 0.5f size means half the size of the parent window
    frameWnd->setSize(UVector2(cegui_reldim(0.5f), cegui_reldim(0.5f)));
    frameWnd->setPosition(UVector2(cegui_reldim(0.25f), cegui_reldim(0.25)) );
    frameWnd->setDragMovingEnabled(true);
    frameWnd->subscribeEvent(CEGUI::FrameWindow::EventMouseButtonDown, CEGUI::Event::Subscriber(&CGUIRender::HandleMouseDown, this) );
    frameWnd->subscribeEvent(CEGUI::FrameWindow::EventMouseButtonUp, CEGUI::Event::Subscriber(&CGUIRender::HandleMouseUp, this) );
    frameWnd->subscribeEvent(CEGUI::FrameWindow::EventMouseMove, CEGUI::Event::Subscriber(&CGUIRender::HandleMouseMove, this) );

    // Set the max and min size for this window. Again, relative to parent window. 1.0f = size of parent window.
    frameWnd->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim(1.0f)) );
    frameWnd->setMinSize(UVector2(cegui_reldim(0.1f), cegui_reldim(0.1f)) );


Any suggestions?

EDIT: Got some help in the chatroom. I converted the client coordinates to relative coordinates and it worked fine.

Return to “Help”

Who is online

Users browsing this forum: Baidu [Spider] and 24 guests