In order to keep track of the current state of the mouse, /mouse_action datums have been created. Mouse actions are unique datums that track the mouse state from hover until the mouse is pressed and released. A new mouse action is created only after client.MouseUp() is called, thus completing a specific mouse action.
The current mouse action is stored on the client in the mouse_action variable. This variable is only valid for the duration of the current mouse action. There will always be a current mouse_action for the duration of the client's lifetime.
Mouse actions have two variables:
/mouse_action.state is an integer value that will be one of the following values:
When a mouse action has never had a mouse button held during its lifetime, it will be in the state MOUSE_HOVER.
When a button has been pressed, but the mouse has not been dragged, the state of the mouse action is MOUSE_HOLD.
If the mouse is released before a drag action starts, the state of the mouse action is MOUSE_RELEASE. The mouse actions state is set to MOUSE_RELEASE after MouseUp() is called, but before a new mouse action replaces the current one on the client.
Once MouseDragStart() has been called, the state of the mouse action is set to MOUSE_DRAG.
Once MouseDrop() or certain MouseUp() actions are called, the state of the mouse action is set to MOUSE_DROP prior to the creation of a new mouse_action to replace the current one.
/mouse_action.data should not be accessed directly unless you wish to override mouse actions to create new behavior. This is not currently recommended or supported. It is recommended to access this data by indexing the mouse action directly as though the datum were a list.
The following properties are recognized by default:
src-object or object or start-object
src-location or location or start-location
src-control or control or start-control
src-params or params or start-params
over-object or end-object
over-location or end-location
over-control or end-control
over-params or end-params
Accessing the properties of a mouse action is simple:
You can also get the state of a mouse object using the same indexing:
world.log << mouse_action["state"]
world.log << mouse_action.state
You can also set the variables of a mouse action, and store additional data in a similar manner:
mouse_action["state"] = MOUSE_DRAG
mouse_action["src-object"] = src
mouse_action["tempdata"] = usr
Note that the temporary data is only valid for the lifetime of the mouse action. If you need to do something with a mouse action over time, be sure to store the mouse action you want to use, as the client will discard it immediately when a new action takes precedence after the next MouseUp() call.