Game Development Community

Binding to the mouse...

by Clark Kromenaker · in Torque Game Engine · 12/06/2005 (8:19 pm) · 4 replies

This is a pretty strange problem...

I have a pretty simple setup here:

-------------------------------------------

function ShowOpt(%val)
{
Canvas.pushDialog(OptionsDlg);
}

playerKeymap.bind(mouse0, "button1", ShowOpt); //right mouse button

--------------------------------------------

However, it completely fails to work in any imaginable way. I think it might have something to do with the GameTSCtrl taking the mouse clicks (I'm using it's onMouseDown() callback to move the player where I click), but I don't know for sure. Binding this to a key works fine, but it does nothing with the mouse.


Any suggestions?

#1
12/06/2005 (11:00 pm)
Err..mouse0 should be mouse (That's what I use without problems, anyway)
#2
12/07/2005 (1:06 pm)
I tried it and

playerKeymap.bind(mouse, "button1", ShowOpt); //right mouse button

doesn't work either...its pretty strange.
#3
12/07/2005 (1:39 pm)
You need to delete your config.cs and config.cs.dso, since these are engine generated files left from before you made your change to default.binds.cs. Once you've deleted them, the engine will re-save them out with your new key/mouse bind.
#4
12/07/2005 (5:56 pm)
I tried that too, but no luck :(.

I think I've had a bit of a breakthrough, though. I'm pretty new to this, so it didn't hit me at first. I added some code to the engine for moving the player model by clicking. It adds an onMouseDown event to the GameTSCtrl, which I think is taking all the click events and the binds do nothing (or at least, that's what I understand from some experimenting with ECHOs). It looks like onMouseDown really only checks for left mouse clicks, though. Is there a callback or function to check for right mouse clicks and, if not, how might I make one? Might there be a function I could call in onMouseDown to check if which button was pressed?


EDIT: Solved! (Its a great feeling)

I found out about the onRightMouseDown callback and simply added it to the GameTSCtrl. The definition simply pointed to the console method, where I do my stuff in script. Excellent!

Thanks for the help guys. Its really appreciated, let me tell you!