How to enable middle mouse button events [code]
by Max Kielland · in Torque Game Builder · 02/02/2013 (4:11 pm) · 0 replies
After I had searched high and low in forums and Google I came to the conclusion that something must have been broken in the source somewhere.
It took me just about 5 minutes to find where to do the change and recompile.
In t2dSceneWindow.h add these declarations att the bottom somewhere after the other onXxxxMouse events.
In t2dSceneWindow.cc add the following functions somewhere (preferable after the other on mouse functions).
As you can see in the code, there are already functions for the mouse wheel scroll as well:
Enjoy!
It took me just about 5 minutes to find where to do the change and recompile.
In t2dSceneWindow.h add these declarations att the bottom somewhere after the other onXxxxMouse events.
void onMiddleMouseDown(const GuiEvent &event); void onMiddleMouseUp(const GuiEvent &event); void onMiddleMouseDragged(const GuiEvent &event);
In t2dSceneWindow.cc add the following functions somewhere (preferable after the other on mouse functions).
//-----------------------------------------------------------------------------
// Mouse Event Handler.
//-----------------------------------------------------------------------------
void t2dSceneWindow::onMiddleMouseDown( const GuiEvent& event )
{
// Lock Mouse (if necessary).
if(mLockMouse)
mouseLock();
// Dispatch Mouse Event.
dispatchMouseEvent("onMiddleMouseDown", event);
}
//-----------------------------------------------------------------------------
// Mouse Event Handler.
//-----------------------------------------------------------------------------
void t2dSceneWindow::onMiddleMouseUp( const GuiEvent& event )
{
// Lock Mouse (if necessary).
if(mLockMouse)
mouseUnlock();
// Dispatch Mouse Event.
dispatchMouseEvent("onMiddleMouseUp", event);
}
//-----------------------------------------------------------------------------
// Mouse Event Handler.
//-----------------------------------------------------------------------------
void t2dSceneWindow::onMiddleMouseDragged( const GuiEvent& event )
{
// Dispatch Mouse Event.
dispatchMouseEvent("onMiddleMouseDragged", event);
}As you can see in the code, there are already functions for the mouse wheel scroll as well:
onMouseWheelUp onMouseWheelDown
Enjoy!
About the author
Owner of MK Development www.mkdevelopment.se