Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8345159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:35:42+00:00 2026-06-09T06:35:42+00:00

I have an application using the Ogre3D to create multiple render windows, and I’m

  • 0

I have an application using the Ogre3D to create multiple render windows, and I’m using the solution posted here to support non-exclusive mouse input to these windows. However, I find that I have to physically click on a render window before it regains focus, whereas I’d really like the render windows to gain focus on a mouseover event. Is it possible to capture a mouseover event on an unfocused render window in Ogre3D/OIS and then subsequently set the focus for the render window?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:35:43+00:00Added an answer on June 9, 2026 at 6:35 am

    To support this kind of functionality using Ogre3D in Windows, I had to implement a singleton object that kept a collection of all of the instantiated displays.

    class InputProcessor
    {
        /// @name Types
        /// @{
    public:
        /// @}
    
        /// @name InputProcessor implementation
        /// @{
    public:
        void addDisplay(Display* _pDisplay);
    
        bool processMouseMoved(int _x, int _y, int _z, int _keyModifier);
        bool processMousePressed(int _keyModifier, int _id);
        bool processMouseReleased(int _keyModifier, int _id);
    
        static InputProcessor& getSingleton();
        /// @}
    
        /// @name 'Structors
        /// @{
    private:
         InputProcessor();
        ~InputProcessor();
        /// @}
    
        /// @name Member Variables
        /// @{
    private:
        typedef std::set<Display*>     Displays_type;
        Displays_type                  m_displays;
        /// @}
    
    };  // class InputProcessor
    

    Then, in my UIFrameListener (which derives from Ogre3D’s ExampleFrameListener), I transform the mouse window coordinates to global screen coordinates. If the mouse happens to reside outside of the window region, I apply the relative mouse movement to the last recorded mouse position; otherwise, I simply apply the absolute mouse position within the window:

    bool
    UIFrameListener::mouseMoved(const OIS::MouseEvent& e)
    {
        int keyModifierState = GetKeyModifierState();
        int windowLeft = m_display.getLeft();
        int windowTop = m_display.getTop();
        int windowWidth = m_display.m_pWindow->getWidth();
        int windowHeight = m_display.m_pWindow->getHeight();
    
        if (e.state.X.abs != 0 && e.state.X.abs != windowWidth)
        {
            m_lastX = e.state.X.abs;
        }
        else
        {
            m_lastX += e.state.X.rel;
        }
        int x = windowLeft + (m_display.m_width * m_lastX) / windowWidth;
    
        if (e.state.Y.abs != 0 && e.state.Y.abs != windowHeight)
        {
            m_lastY = e.state.Y.abs;
        }
        else
        {
            m_lastY += e.state.Y.rel;
        }
        int y = windowTop + (m_display.m_height * m_lastY) / windowHeight;
    
        int z = 0;
        if (e.state.Z.rel != 0)
        {
            z = e.state.Z.rel / -120;
        }
    
        return InputProcessor::getSingleton().processMouseMoved(x, y, z, keyModifierState);
    }
    

    And in InputProcessor::processMouseMoved(), I determine which window the mouse cursor is in (if any), and then set the focus appropriately, i.e.

    bool
    InputProcessor::processMouseMoved(int _x,
                                      int _y,
                                      int _z,
                                      int _keyModifier)
    {
        bool found = false;
    
        Displays_type::iterator iter = m_displays.begin();
        while (iter != m_displays.end() && !found)
        {
            int left = (*iter)->getLeft();
            int top = (*iter)->getTop();
            int width = (*iter)->m_pWindow->getWidth();
            int height = (*iter)->m_pWindow->getHeight();
    
            if (left <= _x && left + width  > _x &&
                top  <= _y && top  + height > _y)
            {
                found = true;
            }
            else
            {
                iter++;
            }
        }
    
        if (iter != m_displays.end())
        {
            int left = (*iter)->getLeft();
            int top = (*iter)->getTop();
    
            (*iter)->m_pContext->ProcessMouseMove(
                _x - left, _y - top, _keyModifier
            );
    
            (*iter)->m_pContext->ProcessMouseWheel(_z, _keyModifier);
    
            if (!(*iter)->hasFocus())
            {
                (*iter)->setFocus(true);
            }
        }
    
        return true;
    }
    

    And in the implementation of Display, I have a method Display::setFocus() that sets the focus on the appropriate window:

    void
    Display::setFocus(bool _hasFocus)
    {
        if (m_handle != NULL && _hasFocus)
        {
            SetFocus(m_handle);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application using vanilla OpenID support from GAE platform. I use user_id()
Currently we have developed application using Java 6 based on windows 32bit(Dual core &
I am implementing scripting for my Ogre3d based application using Lua and I have
I have an application using Java servlets/JSP's. There are multiple clients using my app,
I have an application using zend_gdata and create contact with the code below. $doc
I have an application using MySQL 5.5 db in a windows machine and a
I have an application using QtWebKit. It loads URLs and exports some stats on
I have an application using FeedbackPanel to show the user the results of posting
We have an application using the IBM Informix driver. Whenever we try to open
I have an application using the Google Maps javscript API and the Infobox plug-in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.