Can not call script function from C++ in Troque3D Beta3
by Accounts Payable · in Torque 3D Professional · 07/06/2009 (7:48 pm) · 2 replies
Greetings!
Introduction
below is the modifications of my source code:
file "GameTSCtrl.h"
class GameTSCtrl : public GuiTSCtrl
{
Point3F mMouse2DPos;
static void initPersistFields();
void onRightMouseDown( const GuiEvent &event);
void onRightMouseUp( const GuiEvent &event);
};
file "GameTSCtrl.cpp"
void GameTSCtrl::initPersistFields()
{
Parent::initPersistFields();
addField("mMouse2DPos", TypePoint3F, Offset(mMouse2DPos, GameTSCtrl));
}
void GameTSCtrl::onRightMouseDown( const GuiEvent &evt) {
mMouse2DPos = getRoot()->getCursorPos();
if ( isMethod("onRightMouseDown") )
{
Con::executef( this, "onRightMouseDown" );
}
Con::printf("onRightMouseDown x=%d, y=%d", mMouse2DPos.x, mMouse2DPos.y);
}
void GameTSCtrl::onRightMouseUp( const GuiEvent &evt) {
mMouse2DPos= getRoot()->getCursorPos();
if ( isMethod("onRightMouseUp") )
{
Con::executef(this, "onRightMouseUp");
}
Con::printf("onRightMouseUp x=%d, y=%d", mMouse2DPos.x, mMouse2DPos.y);
}
Script file "PlayGui.gui"
%guiContent = new GameTSCtrl(PlayGui) {
canSaveDynamicFields = "1";
profile = "GuiContentProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "0 0";
extent = "640 480";
minExtent = "8 8";
visible = "1";
cameraZRot = "0";
forceFOV = "0";
noCursor = "1";
};
function PlayGui::onRightMouseDown(%this)
{
echo("Right Mouse Down");
}
function PlayGui::onRightMouseUp(%this)
{
echo("Right Mouse Up");
}
Problem Statement
The "onRightMouseDown" and "onRightMouseUp" functions are can not be called from GameTSCtrl.cpp
Any ideas?
Introduction
below is the modifications of my source code:
file "GameTSCtrl.h"
class GameTSCtrl : public GuiTSCtrl
{
Point3F mMouse2DPos;
static void initPersistFields();
void onRightMouseDown( const GuiEvent &event);
void onRightMouseUp( const GuiEvent &event);
};
file "GameTSCtrl.cpp"
void GameTSCtrl::initPersistFields()
{
Parent::initPersistFields();
addField("mMouse2DPos", TypePoint3F, Offset(mMouse2DPos, GameTSCtrl));
}
void GameTSCtrl::onRightMouseDown( const GuiEvent &evt) {
mMouse2DPos = getRoot()->getCursorPos();
if ( isMethod("onRightMouseDown") )
{
Con::executef( this, "onRightMouseDown" );
}
Con::printf("onRightMouseDown x=%d, y=%d", mMouse2DPos.x, mMouse2DPos.y);
}
void GameTSCtrl::onRightMouseUp( const GuiEvent &evt) {
mMouse2DPos= getRoot()->getCursorPos();
if ( isMethod("onRightMouseUp") )
{
Con::executef(this, "onRightMouseUp");
}
Con::printf("onRightMouseUp x=%d, y=%d", mMouse2DPos.x, mMouse2DPos.y);
}
Script file "PlayGui.gui"
%guiContent = new GameTSCtrl(PlayGui) {
canSaveDynamicFields = "1";
profile = "GuiContentProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "0 0";
extent = "640 480";
minExtent = "8 8";
visible = "1";
cameraZRot = "0";
forceFOV = "0";
noCursor = "1";
};
function PlayGui::onRightMouseDown(%this)
{
echo("Right Mouse Down");
}
function PlayGui::onRightMouseUp(%this)
{
echo("Right Mouse Up");
}
Problem Statement
The "onRightMouseDown" and "onRightMouseUp" functions are can not be called from GameTSCtrl.cpp
Any ideas?
#2
07/06/2009 (11:24 pm)
yes, the c++ function are not called as well. I just changed noCursor = "0"; with "noCursor = "1"; it works now. thanks.
Associate Jaimi McEntire
King of Flapjacks