-
-
Notifications
You must be signed in to change notification settings - Fork 108
Hover
Hover works by using a lot of event handlers in a bottom up way. Basically the area checks if the mouse is inside, instead of the mouse pointer being checked for overlap with the area.
In add(), if a cursor is given in the opt, an onHover event handler is attached which sets the cursor. This is actually bugged, since setting a cursor later won't add this handler, and nothing will happen.
Good:
- If not used, there is no extra CPU used.
Bad:
- If used, uses expensive onHover.
- Does not work if starting with a null cursor and setting one afterwards.
- This does not look at draw order, so the cursor used may not be the one of the topmost object.
We may just fix this, by making cursor a setter and using the new onHover. Or we may add cursor processing to the hover system. The draw order might need to be taken into account.
Uses isHovering, which checks whether the mouse is in the area.
The isClicked method (which should be a property I think) checks isPressed and isHovering.
The onClick event is an onPress handler which checks isHovering.
The onHover, onHoverUpdate and onHoverEnd events are all onUpdate handlers which use isHovering.
The hover system checks what is under the cursor and triggers the required events. To make it efficient, we should actually have a hover() component, so only objects using hover are checked.
