OnMiddleMouseDown...?
by David Taylor · in Torque Game Builder · 11/28/2008 (6:03 pm) · 7 replies
As far as I can tell, there aren't any functions in TGB that callback when the user clicks the middle mouse button or scroll wheel. How would I go about creating one so that I can access this functionality? I would have put this in the suggestions forum but I'd love to get it going without having to wait for an update. ;)
About the author
#2
11/28/2008 (6:52 pm)
@Kevin: Thanks. I've had a look, and it does seem feasible. Button2 is the middle button, apparently. I'll give that a go later today. :)
#3
All to no avail. No errors, but no callbacks, either. If I change the device from mouse to keyboard, and button2 to "a", it displays the two echoes.
I got button2 from this link, about a third down the page: http://www.garagegames.com/docs/tgea/official/content/documentation/Scripting%20Reference/Console%20Objects/Torque_Console_Objects_1.html
The only other thing I can think of is trying random button numbers, but even button0 and button1 have returned no response from the other buttons.
Can anyone have a look at the calls that TGB uses for onMouseDown and onMouseRightDown? I'm sure I could base it off that, could I not?
11/29/2008 (2:53 pm)
@Kevin: Thanks for the advice, but I've had no luck. Here's what I've tried:function setupKeybinds()
{
new ActionMap(middleMouseButtonMap);
middleMouseButtonMap.push();
middleMouseButtonMap.bindCmd(mouse, button2, "onMiddleMouseDown();", "onMiddleMouseUp();");
}
function onMiddleMouseDown()
{
echo("Middle mouse button pressed!");
}
function onMiddleMouseUp()
{
echo("Middle mouse button not pressed!");
}All to no avail. No errors, but no callbacks, either. If I change the device from mouse to keyboard, and button2 to "a", it displays the two echoes.
I got button2 from this link, about a third down the page: http://www.garagegames.com/docs/tgea/official/content/documentation/Scripting%20Reference/Console%20Objects/Torque_Console_Objects_1.html
The only other thing I can think of is trying random button numbers, but even button0 and button1 have returned no response from the other buttons.
Can anyone have a look at the calls that TGB uses for onMouseDown and onMouseRightDown? I'm sure I could base it off that, could I not?
#4
try: "mouse0", "mouse1" and "mouse2". One of them may work, trying anything past mouse2 is probably futile.
You mean the C++ code? Okay, take how hard you think it will be, and multiply that by 10x and you will have a safe estimate of how difficult it will be to duplicate that function for a middle mouse button. If you aren't a C++ programmer, don't even try it.
11/29/2008 (8:58 pm)
Instead of "mouse"try: "mouse0", "mouse1" and "mouse2". One of them may work, trying anything past mouse2 is probably futile.
Quote:Can anyone have a look at the calls that TGB uses for onMouseDown and onMouseRightDown? I'm sure I could base it off that, could I not?
You mean the C++ code? Okay, take how hard you think it will be, and multiply that by 10x and you will have a safe estimate of how difficult it will be to duplicate that function for a middle mouse button. If you aren't a C++ programmer, don't even try it.
#5
That's what I was getting at with the calls. I didn't mean the C++ code, even though I have a little bit of background in it. I meant the calls that onMouseDown calls when the left mouse button is pressed. It should be a variation of that, I would have assumed.
Either way, I can't access *any* mouse button clicks through the bindCmd call, which I do find a bit odd. I've also got a keyboard one that is identical and gets called when I press the right key.
11/30/2008 (2:42 pm)
Yeah, I've gone through from mouse, mouse0, all the way through to mouse9, and from button0 to button9 on all of them, and still nothing. But it's not registering left mouse clicks or right mouse clicks through the same code, either.That's what I was getting at with the calls. I didn't mean the C++ code, even though I have a little bit of background in it. I meant the calls that onMouseDown calls when the left mouse button is pressed. It should be a variation of that, I would have assumed.
Either way, I can't access *any* mouse button clicks through the bindCmd call, which I do find a bit odd. I've also got a keyboard one that is identical and gets called when I press the right key.
#6
11/30/2008 (3:57 pm)
Yeah, I knew that the mouse commands through action maps USED to be broken, but I thought that they were quite fixed by now. Sorry, David.
#7
I can use onMouseDown and onRightMouseDown for the other buttons, and I'll just use a keyboard key for the middle button in the meantime. I think I'll also add a thread to Melv's forum in the hope that it'll get fixed in the not too distant future. :)
11/30/2008 (4:06 pm)
All good, Kevin. (Unless you're apologising because you're personally responsible for breaking the action maps! Haha!)I can use onMouseDown and onRightMouseDown for the other buttons, and I'll just use a keyboard key for the middle button in the meantime. I think I'll also add a thread to Melv's forum in the hope that it'll get fixed in the not too distant future. :)
Torque Owner Kevin James