How to get mouse and keyboard working?


13-05-2008 06:00:12

Well, I followed the sample to set up my application...

Here´s the .h code:

#ifndef C_GUI_H
#define C_GUI_H

#include <OIS/OIS.h>
#include "Ogre.h"
#include "QuickGUI.h"

using namespace OIS;

class cGUI : public MouseListener, public KeyListener
Keyboard* oisKeyboard;
Mouse* oisMouse;
QuickGUI::GUIManager* GUIManager;
QuickGUI::Sheet* sheet;
QuickGUI::TextBox* mouseOverTB;
QuickGUI::Window* CBTestWindow;
QuickGUI::ComboBox* colorCB;


cGUI(Mouse*, Ogre::SceneManager*, OIS::Keyboard*);
void init();
void update(const Ogre::FrameEvent &evt);
void selectionMade(const QuickGUI::EventArgs& args);
bool mouseMoved( const OIS::MouseEvent &e );
bool mousePressed( const OIS::MouseEvent &e, OIS::MouseButtonID id );
bool mouseReleased( const OIS::MouseEvent &e, OIS::MouseButtonID id );
bool keyPressed( const OIS::KeyEvent &arg );
bool keyReleased( const OIS::KeyEvent &arg );


So I set the callbacks with oisMouse and keyboard setEventCallback method...

And the callback functions like the demo.

Also the update with GUIManager->injectTime();

What more I need to do to get it working?

I have this and no interation at all:

Thanks in advance.


13-05-2008 18:30:45

Assuming you've registered your callbacks with OIS, they will be called when you have keyboard/mouse input. In order to apply this input to the GUI, you have to inject it. (mGUIManager->inject...)

Examples of how to inject mouse/keyboard events can be found here:


13-05-2008 20:41:32

I did it...

cGUI::cGUI(Mouse* m, Ogre::SceneManager *sceneMgr, OIS::Keyboard* kB) : oisMouse(m), oisKeyboard(kB)
new QuickGUI::Root();
GUIManager = QuickGUI::Root::getSingleton().createGUIManager(sceneMgr->getCamera("MainCamera")->getViewport(),"qgui");


void cGUI::update(const Ogre::FrameEvent &evt)

bool cGUI::mouseMoved( const OIS::MouseEvent &arg ){

GUIManager->injectMouseMove( arg.state.X.rel, arg.state.Y.rel );
return true;
bool cGUI::mousePressed( const OIS::MouseEvent &e, OIS::MouseButtonID id ){

return true;
bool cGUI::mouseReleased( const OIS::MouseEvent &e, OIS::MouseButtonID id ){

return true;

bool cGUI::keyReleased( const OIS::KeyEvent &arg )
return true;

bool cGUI::keyPressed( const OIS::KeyEvent &arg )
GUIManager->injectChar( arg.text );
return true;

QuickGUI::registerScriptParser(); is called in other place, but before resources like you saied in the tutorial...


13-05-2008 21:11:32

As I see on Debug, mouseMoved and etc are never called :cry:


13-05-2008 23:16:34

Thats an OIS issue you're having. I'm not sure what the problem is, since you're setting your keyboard and mouse eventCallback functions. Whats your code for initializing OIS? Are you following the example framework code? Make sure you're calling "capture" on your keyboard and mouse to capture events.


14-05-2008 01:26:46

Now its OK, The mouse and keyboard need to be buffered...

In fact I tried it once, but I didnt see the mouse because it was hiding...

So, my other problem is the clipping... How can I fix that?



14-05-2008 05:41:36

Is the Platform a 3d overlay? In your first screenshot it looks like the platform is blocking the UI, and I've only seen issues with Overlays. (Is this what you mean by clipping?)


15-05-2008 03:04:42

Is the Platform a 3d overlay? In your first screenshot it looks like the platform is blocking the UI, and I've only seen issues with Overlays. (Is this what you mean by clipping?)

Yes, I guessed that clipping was that :oops:


15-05-2008 08:33:32

You can try setting the Render Queue to the last one, which is RENDER_QUEUE_MAX. Make sure you call

RenderQueue::getQueueGroup( RENDER_QUEUE_MAX )

to ensure the QueueGroup is created.

The function is GUIManager::setRenderQueueID