How to get "onMiddleMouseDragged" function working?
by Sean Oloughlin · in Torque Game Builder · 08/13/2012 (8:38 pm) · 2 replies
I want to be able to rotate the camera when i move my mouse with the middle mouse button down but i can seem to get it working right
heres the "onMiddleMouseDragged" call back in gameTSCtrl.cpp
"middleMouseIsDown" is a Boolean and is set to true when the "onMiddleMouseDown" function is called
and in script i have a function in playGui.cs
that doesnt run at all? any ideas?
thanks.
heres the "onMiddleMouseDragged" call back in gameTSCtrl.cpp
void GameTSCtrl::onMouseMove(const GuiEvent &evt)
{
if(isMethod("onMiddleMouseDragged") && middleMouseIsDown)
{
makeScriptCall( "onMiddleMouseDragged", evt );
}
}"middleMouseIsDown" is a Boolean and is set to true when the "onMiddleMouseDown" function is called
void GameTSCtrl::onMiddleMouseDown(const GuiEvent &evt)
{
Parent::onMiddleMouseDown(evt);
if( isMethod( "onMiddleMouseDown" ) )
makeScriptCall( "onMiddleMouseDown", evt );
Con::errorf("Pressed!");
middleMouseIsDown = true;
}and in script i have a function in playGui.cs
function PlayGui::onMiddleMouseDragged(%this, %pos, %start, %ray)
{
echo("middle mouse was dragged!");
}that doesnt run at all? any ideas?
thanks.
Torque Owner Guy Allard
Default Studio Name
in gameTSCtrl.h,
after:
virtual void onMiddleMouseUp(const GuiEvent &evt);
add:
virtual void onMiddleMouseDragged(const GuiEvent &evt);
then in gameTSCtrl.cpp,
add the function
void GameTSCtrl::onMiddleMouseDragged(const GuiEvent &evt) { Parent::onMiddleMouseDragged(evt); if( isMethod( "onMiddleMouseDragged" ) ) makeScriptCall( "onMiddleMouseDragged", evt ); }The reason that your version doesn't work is that onMouseMove doesn't get called when you are dragging, the relevant on-Dragged function is called instead when the mouse is moved while a button is pressed.