Game Development Community

MouseUp Events missing?

by Bryan Morgan · in Torque 3D Professional · 10/17/2009 (5:13 pm) · 5 replies

I'm not yet sure if this is a bug, but I can't seem to get MouseUp events to work in PlayGui. First I tried to implement a simple cursor toggle system like so, which would allow me to move my orbit camera while the middle mouse is held:
function PlayGui::onMiddleMouseDown(%this, %pos, %start, %ray){
   echo("Middle Mouse Down");
   hideCursor();
}

function PlayGui::onMiddleMouseUp(%this, %pos, %start, %ray){
   echo("Middle Mouse Up");
   showCursor();
}
Unfortunately this doesn't seem to work as the onMiddleMouseUp function is never entered. I even tried just using onMouseUp as that function is actually mentioned in the RTS Prototype example, but it is also never called by the GUI. Is there something wrong with my code? Has anyone else done this successfully?

EDIT: Actually it looks like while the cursor is disabled, the mouse buttons are suddenly ignored until the cursor is shown again. Is hiding the cursor the only way to give movement control of the camera to the mouse, or is there another way to do what I'm trying to do?

#1
10/17/2009 (9:50 pm)
We have two threads talking about this, i don't have a solution for this yet, and nobody seems to know or help with this. :(

see the threads

http://www.garagegames.com/community/forums/viewthread/103719

http://www.garagegames.com/community/forums/viewthread/103493
#2
10/18/2009 (12:34 am)
Those threads aren't exactly the same thing. The first thread specifically states that onRightMouseUp works, and that second post(your post) is asking how to do what I'm trying to do, but I already know how to do what I want to do. The problem I'm having is that none of the onMouseUp family of functions are being entered regardless of what the mouse buttons are doing as shown by trying to echo in those functions and not getting anything back. I'll probably need to just see where the code is handled in the engine and tell it to continue polling the mouse regardless of if the cursor is shown or not.
#3
10/18/2009 (8:47 pm)
It's because when the cursor is hidden, it's sending the input events to the actionmaps. The GUI isn't getting them at all. Also, if you try to get it to respond to a mouse up via the actionmaps immediately after that input is eaten up by the GUI system (in a GUI callback, hiding the cursor) it'll think of it as a mouse down, probably because it simply counts the events to get the difference between a mouse down event and a mouse up event.

I implemented a small hack to get around this in TGE, I'll see if I can dig it up. It sent the input event to the actionmap upon receiving the event on the GuiCanvas (with a flag variable to enable/disable that behavior).

EDIT: I was wrong, I actually sent out a call to onRightMouseUp implementations (that's the only event I actually cared about) in the GuiCanvas::processInputEvent function. That function was called on any input event, GUI or actionmap, it just never grabbed anything because it was constantly looking for the cursor to be on.
#4
10/18/2009 (9:35 pm)
Looking at the Torque3D equivalent of where I put my TGE solution, it's not going to be a simple drag and drop. I'll be implementing a Torque3D version in the near future, so perhaps I'll come back and post it then.

In the meantime, if you care to chase it yourself, start with GuiCanvas::processInputEvent() in guiCanvas.cpp. You'll notice that it doesn't enter the mouse event function if the cursor isn't on.
#5
10/18/2009 (10:07 pm)
Yeah, I've actually been looking at that as a possible fix already. Thanks for verifying it though. I'm currently in the process of moving my website to another server and doing some major redesigns so I've not looked much at it.