Module lib.manager
Internal button press management machinery.
Manage press and release events. Objects in the renderable heirarchy
might move around between press and release, so that matching calls to
press()
on an object might have mismatched coordinates - or the calls
may not occur in matching pairs at all. Hence, we retain the object
and coordinates for every successful press-on, indexed against actual
grid coordinates, so that we can always deliver the corresponding
release.
Functions
PressManager:new (target) | The PressManager maintains a two-dimensional map from device (x, y) to
RouteResult , which encapsulates a press: it holds the (x, y) position
of the original press-down on the target object, and the target itself. |
PressManager:press (x, y, how) | Route a button press. |
PressManager:release (x, y) | Route a button release. |
RouteResult:new (target, x, y) | A new routing result. |
RouteResult:release () | Handle a button release. |
Functions
- PressManager:new (target)
-
The
PressManager
maintains a two-dimensional map from device(x, y)
toRouteResult
, which encapsulates a press: it holds the(x, y)
position of the original press-down on the target object, and the target itself. It has arelease()
method to send through a release to the target at the same coordinates, even if the target has moved (in location, and/or in the object heirarchy).Parameters:
- target the top-level shado object handling button presses (and releases)
Returns:
-
a press manager
- PressManager:press (x, y, how)
-
Route a button press. If the object (or object heirarchy) handles
the press, remember the object and location so that a release can be correctly
routed to match.
Parameters:
- x the X coordinate
- y the Y coordinate
- how
1
for press,0
for release
- PressManager:release (x, y)
-
Route a button release. We look for a stored button press
in the same physical location.
Parameters:
- x the X coordinate
- y the Y coordinate
- RouteResult:new (target, x, y)
-
A new routing result.
Parameters:
- target the shado object handling the press
- x the X coordinate
- y the Y coordinate
Returns:
-
a route result
- RouteResult:release ()
- Handle a button release. Action the release at the correct location on the correct object.