Ogre 1.7 exclusive use of the mouse (move the mouse out of the current window)

Source: Internet
Author: User

The Internet has already solved the mouse exclusive problemArticleFor example, ogre + cegui + OIS perfectly solves the non-exclusive use of the mouse, and there is also an article on this basis to solve the no pointer problem of the mouse in the window border, for example, the ogre + cegui + OIS mouse is not exclusively used
(Including code). These articles provide a complete solution to solve the mouse exclusive problem. However, they are applicable to the ogre 1.6.x version and are not applicable to the new ogre version 1.7.x. Ogre 1.7 uses a system called "Tray ".CodeIn the sdktray. h file. Sdktray uses ogre overlay to implement the GUI, And ogre 1.7 seems to have more Gui-related components (details) than earlier versions ). In short, we need to modify the corresponding code to achieve mouse monopoly.

There are two steps to solve this problem:

(1) solve the mouse exclusive problem

(2) solve the mouse display problem

(1) modify the setupinput function in samplecontext. h to achieve mouse exclusive. The Code is as follows:

Virtual void setupinput () <br/>{< br/> showcursor (0); // ** <br/> ois: paramlist pl; <br/> size_t winhandle = 0; <br/> STD: ostringstream winhandlestr; <br/> mwindow-> getcustomattribute ("window", & winhandle ); <br/> winhandlestr <winhandle; <br/> Pl. insert (STD: make_pair ("window", winhandlestr. STR (); <br/> Pl. insert (STD: make_pair (STD: string ("w32_mouse"), STD: string ("discl_foreground"); // ** <br/> Pl. insert (STD: make_pair (STD: string ("w32_mouse"), STD: string ("discl_nonexclusive "))); // ** <br/> minputmgr = ois: inputmanager: createinputsystem (PL); <br/> createinputdevices (); // create the specific input devices <br/> windowresized (mwindow); // do an initial adjustment of mouse area <br/>} 

(2) modify the mousemoved function in sdksample. h to display the mouse. The Code is as follows:

 

Virtual bool mousemoved (const ois: mouseevent & EVT) <br/>{< br/> If (EVT. state. x. ABS <mwindow-> getviewport (0)-> getactualleft () + 1 <br/> | (EVT. state. y. ABS <mwindow-> getviewport (0)-> getactualtop () + 1) <br/> | (EVT. state. x. ABS> mwindow-> getviewport (0)-> getactualleft () + mwindow-> getviewport (0)-> getactualwidth () <br/> | (EVT. state. y. ABS> mwindow-> getviewport (0)-> getactualtop () + mwindow-> getviewport (0)-> G Etactualheight () <br/>{< br/> If (! Msysmouseshowflag) <br/>{< br/> showcursor (1); <br/> mtraymgr-> hidecursor (); <br/> msysmouseshowflag = true; <br/>}< br/> else <br/> {<br/> If (msysmouseshowflag) <br/>{< br/> showcursor (0); <br/> mtraymgr-> showcursor (); <br/> msysmouseshowflag = false; <br/>}< br/> If (mtraymgr-> injectmousemove (EVT) return true; <br/> mcameraman-> injectmousemove (EVT ); <br/> return true; <br/>}

 

Do not forget to define bool msysmouseshowflag and initialize it to false.

 

In this way, the mouse exclusive problem is solved and the mouse can be properly displayed.

 

By cgnerds@gmail.com
Time:, 2011/06/21

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.