Game Development Community

Handling mouse wheel & other events - bug ?

by Orion Elenzil · in Torque Game Engine · 01/09/2006 (5:15 pm) · 1 replies

Hi All,

so i wanted the mousewheel to be linked to camera zoom,
so i bound ZAXIS to a function which adjusts camera zoom, and it's a beautiful thing.

the complication comes in when i have GuiControls which also respond to mousewheel,
such as the chat hud or any GuiListCtrl.
the GuiListCtrl handles but doesn't swallow the event, so Zaxis is still triggered,
so scrolling thru your chat history results in a camera zoom as well.

this turns out to be because
void GuiCanvas::rootMouseWheelDown()
is a void and thus not passing back the bool which mMouseControl->onMouseWheelDown() returns,
which is the indicator for whether some control handled the event or not.

so i changed GuiCanvas::rootMouseWheelDown() to a bool and had it return the appropriate values and life seems good again: the mouseWheel event is passed to ZAXIS unless it's over a control which handles the event.

my question is:

This seems like a pretty glaring break in the event-handling pipeline,
so glaring that i'm tempted to think it's a feature and not a bug.
Additionally this behaviour is happening for pretty much all the mouse events,
and i'm nervous about 'fixing' it for all of them.

I guess i didn't phrase that as a question.
My question is:
should the following voids be changed to bools and appropriately returned from
bool GuiCanvas::processInputEvent
, and if not why not ?

Here's the void functions i think should be bools:
GuiCanvas.h
/// @name Mouse input methods
   /// These events process the events before passing them down to the
   /// controls they effect. This allows for things such as the input 
   /// locking and such. 
   ///
   /// Each of these methods corosponds to the action in it's method name
   /// and processes the GuiEvent passd as a parameter
   /// @{
   void rootMouseUp(const GuiEvent &event);
   void rootMouseDown(const GuiEvent &event);
   void rootMouseMove(const GuiEvent &event);
   void rootMouseDragged(const GuiEvent &event);

   void rootRightMouseDown(const GuiEvent &event);
   void rootRightMouseUp(const GuiEvent &event);
   void rootRightMouseDragged(const GuiEvent &event);

   bool rootMouseWheelUp(const GuiEvent &event);
   bool rootMouseWheelDown(const GuiEvent &event);
   /// @}

#1
01/09/2006 (5:16 pm)
Note -
there is at least one other way to get around this but it's much dirtier.
that way is to expose GuiCanvas::getMouseControl() to script,
and in the ZAXIS handler in script, check to make sure that the mouseControl is ShapeNameHud.