59
« on: September 07, 2015, 11:03:01 PM »
object.dump() will not reveal engine callbacks such as object::onMouseEnter() if they have not been defined already. However, if you do define one of these particular callbacks, then the engine will call it for you appropriately. The callback ::onMouseEnter() is not restricted to GuiMouseEventCtrl objects.
Here is a snippet from guiControl.h from the Torque2D engine
// Copyright (c) 2013 GarageGames, LLC
#ifndef _GUICONTROL_H_
#define _GUICONTROL_H_
/// @defgroup gui_group Gui System
/// The GUI system in Torque provides a powerful way of creating
/// WYSIWYG User Interfaces for your Game or Application written
/// in Torque.
///
/// The GUI Provides a range of different controls that you may use
/// to arrange and layout your GUI's, including Buttons, Lists, Bitmaps
/// Windows, Containers, and HUD elements.
///
/// The Base Control Class GuiControl provides a basis upon which to
/// write GuiControl's that may be specific to your particular type
/// of game.
/// @addtogroup gui_core_group Core
/// @section GuiControl_Intro Introduction
///
/// GuiControl is the base class for GUI controls in Torque. It provides these
/// basic areas of functionality:
/// - Inherits from SimGroup, so that controls can have children.
/// - Interfacing with a GuiControlProfile.
/// - An abstraction from the details of handling user input
/// and so forth, providing friendly hooks like onMouseEnter(), onMouseMove(),
/// and onMouseLeave(), onKeyDown(), and so forth.
/// - An abstraction from the details of rendering and resizing.
/// - Helper functions to manipulate the mouse (mouseLock and
/// mouseUnlock), and convert coordinates (localToGlobalCoord() and
/// globalToLocalCoord()).
///
/// @ref GUI has an overview of the GUI system.
///
///
/// @ingroup gui_group Gui System
/// @{
class GuiControl : public SimGroup
{
private:
typedef SimGroup Parent;
typedef GuiControl Children;
public:
/// Called when a child control of the object is resized
/// @param child Child object
virtual void childResized(GuiControl *child);
/// @name Rendering
/// Called when this control is to render itself
/// @param offset The location this control is to begin rendering
/// @param updateRect The screen area this control has drawing access to
virtual void onRender(Point2I offset, const RectI &updateRect);
/// @name Events
///
/// If you subclass these, make sure to call the Parent::'s versions.
/// Called when this object is asked to wake up returns true if it's actually awake at the end
virtual bool onWake();
/// Called when this object is asked to sleep
virtual void onSleep();
/// Do special pre-render proecessing
virtual void onPreRender();
/// Called when this object is removed
virtual void onRemove();
/// Called when one of this objects children is removed
virtual void onChildRemoved( GuiControl *child );
/// Called when this object is added to the scene
bool onAdd();
/// Called when this object has a new child
virtual void onChildAdded( GuiControl *child );
/// General input handler.
virtual bool onInputEvent(const InputEvent &event);
/// @name Mouse Events
/// These functions are called when the input event which is
/// in the name of the function occurs.
virtual void onMouseUp(const GuiEvent &event);
virtual void onMouseDown(const GuiEvent &event);
virtual void onMouseMove(const GuiEvent &event);
virtual void onMouseDragged(const GuiEvent &event);
virtual void onMouseEnter(const GuiEvent &event);
virtual void onMouseLeave(const GuiEvent &event);
virtual bool onMouseWheelUp(const GuiEvent &event);
virtual bool onMouseWheelDown(const GuiEvent &event);
virtual void onRightMouseDown(const GuiEvent &event);
virtual void onRightMouseUp(const GuiEvent &event);
virtual void onRightMouseDragged(const GuiEvent &event);
virtual void onMiddleMouseDown(const GuiEvent &event);
virtual void onMiddleMouseUp(const GuiEvent &event);
virtual void onMiddleMouseDragged(const GuiEvent &event);
/// @name Editor Mouse Events
///
/// These functions are called when the input event which is
/// in the name of the function occurs. Conversly from normal
/// mouse events, these have a boolean return value that, if
/// they return true, the editor will NOT act on them or be able
/// to respond to this particular event.
///
/// This is particularly useful for when writing controls so that
/// they may become aware of the editor and allow customization
/// of their data or appearance as if they were actually in use.
/// For example, the GuiTabBookCtrl catches on mouse down to select
/// a tab and NOT let the editor do any instant group manipulation.
/// Called when a mouseDown event occurs on a control and the GUI editor is active
/// @param event the GuiEvent which caused the call to this function
/// @param offset the offset which is representative of the units x and y that the editor takes up on screen
virtual bool onMouseDownEditor(const GuiEvent &event, Point2I offset) { return false; };
/// Called when a mouseUp event occurs on a control and the GUI editor is active
/// @param event the GuiEvent which caused the call to this function
/// @param offset the offset which is representative of the units x and y that the editor takes up on screen
virtual bool onMouseUpEditor(const GuiEvent &event, Point2I offset) { return false; };
/// Called when a rightMouseDown event occurs on a control and the GUI editor is active
/// @param event the GuiEvent which caused the call to this function
/// @param offset the offset which is representative of the units x and y that the editor takes up on screen
virtual bool onRightMouseDownEditor(const GuiEvent &event, Point2I offset) { return false; };
/// Called when a mouseDragged event occurs on a control and the GUI editor is active
/// @param event the GuiEvent which caused the call to this function
/// @param offset the offset which is representative of the units x and y that the editor takes up on screen
virtual bool onMouseDraggedEditor(const GuiEvent &event, Point2I offset) { return false; };
/// Occurs when the first responder for this chain is lost
virtual void onLoseFirstResponder();
/// @name Keyboard Events
/// Happens when a key is depressed
/// @param event Event descriptor (which contains the key)
virtual bool onKeyDown(const GuiEvent &event);
/// Happens when a key is released
/// @param event Event descriptor (which contains the key)
virtual bool onKeyUp(const GuiEvent &event);
/// Happens when a key is held down, resulting in repeated keystrokes.
/// @param event Event descriptor (which contains the key)
virtual bool onKeyRepeat(const GuiEvent &event);
/// Occurs when this control performs its "action"
virtual void onAction();
/// @name Peer Messaging
virtual void onMessage(GuiControl *sender, S32 msg); ///< Receive a message from another control
/// Called if this object is a dialog, when it is added to the visible layers
virtual void onDialogPush();
/// Called if this object is a dialog, when it is removed from the visible layers
virtual void onDialogPop();
};
/// @}
#endif