|
Window Framework v1.2.4
Window Framework for Unity UI Toolkit
|
A sophisticated pointer manipulator that manages tooltip behavior for UI elements within the Window Framework. More...
Public Member Functions | |
| TooltipManipulator () | |
| Initializes a new instance of the TooltipManipulator and establishes connection to the tooltip system. | |
Protected Member Functions | |
| override void | RegisterCallbacksOnTarget () |
| Registers pointer and mouse event callbacks on the target element. | |
| override void | UnregisterCallbacksFromTarget () |
| Unregisters all event callbacks from the target element during cleanup. | |
Properties | |
| float | TooltipShowDelay [get] |
| Gets the tooltip display delay from the WindowFrameController settings, converted to seconds. | |
Private Member Functions | |
| void | HideTooltipImmediately () |
| Immediately hides any visible tooltip and cancels all pending tooltip operations. | |
| void | MouseMove (MouseMoveEvent evt) |
| Handles mouse movement events to manage tooltip display timing and cancellation. | |
| void | OnPointerCaptured (PointerCaptureEvent evt) |
| Handles pointer capture events that indicate the start of drag operations. | |
| void | OnPointerCaptureOut (PointerCaptureOutEvent evt) |
| Handles pointer capture release events that indicate the end of drag operations. | |
| void | PointerDown (PointerDownEvent evt) |
| Handles pointer down events to immediately hide tooltips when user interaction begins. | |
| void | PointerEnter (PointerEnterEvent evt) |
| Handles pointer enter events to begin tooltip tracking when cursor enters the element. | |
| void | PointerLeave (PointerLeaveEvent evt) |
| Handles pointer leave events to hide tooltips and stop tracking when cursor exits the element. | |
| void | PointerUp (PointerUpEvent evt) |
| Handles pointer up events to reset dragging state after user interactions. | |
Private Attributes | |
| bool | _isDragging |
| Tracks whether a drag operation is currently in progress. | |
| Vector2 | _lastMousePosition |
| Stores the last recorded mouse position for movement detection. | |
| bool | _mouseIsOverTarget |
| Tracks whether the mouse pointer is currently positioned over the target element. | |
| bool | _tooltipScheduled |
| Indicates whether a tooltip display operation has been scheduled. | |
| IVisualElementScheduledItem | _tooltipTask |
| Reference to the scheduled tooltip display task. | |
| readonly WindowFrameTooltip | _windowFrameTooltip |
| Reference to the Window Framework's tooltip system. | |
Static Private Attributes | |
| const float | MOUSE_MOVEMENT_THRESHOLD = 2f |
| The minimum mouse movement distance (in pixels) required to cancel tooltip display. | |
This manipulator provides intelligent tooltip management that integrates seamlessly with UI interactions:
Key Features:
The manipulator automatically handles complex interaction scenarios such as:
This manipulator is automatically applied to elements with tooltip content when WindowFrameController.ApplyTooltips() is called.
| GWG.WindowFramework.Manipulators.TooltipManipulator.TooltipManipulator | ( | ) |
The constructor attempts to obtain a reference to the Window Framework's tooltip system through the WindowFrameController. If the controller is not available, tooltip functionality will be disabled for this manipulator instance.
The manipulator is designed to gracefully handle scenarios where the WindowFrameController is not yet initialized or is unavailable, ensuring robust operation in various application startup sequences.
|
private |
This method provides immediate tooltip suppression for scenarios where tooltips must be hidden without delay:
Operations Performed:
This method is used in high-priority scenarios such as:
The immediate hiding ensures responsive UI behavior and prevents tooltips from interfering with user interactions.
|
private |
| evt | The mouse move event data containing current cursor position |
This method implements sophisticated mouse movement tracking to provide intelligent tooltip behavior:
Drag Detection:
Movement Analysis:
Tooltip Scheduling:
This creates a natural tooltip experience where tooltips appear when the user pauses over an element but don't interfere with active cursor movement or interactions.
|
private |
| evt | The pointer capture event data |
This method responds to pointer capture events, which typically occur when drag operations begin (such as window dragging or resizing). When pointer capture is detected:
This ensures that tooltips don't interfere with drag operations or remain visible during interactions where they would be distracting or unhelpful.
|
private |
| evt | The pointer capture out event data |
This method responds to pointer capture release events, which occur when drag operations complete. The method resets the dragging state flag, allowing tooltip functionality to resume normal operation.
After this event, if the mouse cursor is still positioned over an element with tooltip content, normal tooltip timing and display logic will resume.
|
private |
| evt | The pointer down event data |
This method ensures that tooltips are immediately hidden when the user clicks on any UI element. This prevents tooltips from remaining visible during interactions and provides immediate visual feedback that user input has been received.
The immediate hiding behavior is important for maintaining responsive UI feel and preventing tooltip content from obscuring important interface elements during user interactions.
|
private |
| evt | The pointer enter event data containing cursor position |
This method initializes tooltip tracking when the cursor first enters the target element:
After this event, the MouseMove event handler will begin monitoring cursor movement and scheduling tooltip display based on movement patterns and timing settings.
|
private |
| evt | The pointer leave event data |
This method performs comprehensive cleanup when the cursor leaves the target element:
State Management:
Tooltip Hiding Logic:
This approach provides smooth user experience by using immediate hiding for tooltips that are still appearing while allowing visible tooltips to fade out gracefully.
|
private |
| evt | The pointer up event data |
This method ensures that the dragging state is properly reset when pointer interactions complete. While the primary drag state management occurs through pointer capture events, this provides an additional safety net to ensure tooltip functionality is restored after any interaction sequence.
This helps maintain consistent tooltip behavior even in complex interaction scenarios where pointer capture events might not fire as expected.
|
protected |
This method establishes comprehensive event handling for tooltip behavior by registering callbacks for all relevant interaction events:
Pointer Events:
Mouse Events:
Capture Events:
The comprehensive event coverage ensures tooltips behave intelligently across all common user interaction patterns.
|
protected |
This method ensures proper cleanup by removing all event callbacks that were registered during initialization. It prevents memory leaks and ensures that the manipulator doesn't continue processing events after removal.
The method mirrors RegisterCallbacksOnTarget() by unregistering every callback that was originally registered, maintaining perfect cleanup symmetry.
|
private |
Set to true when pointer capture events indicate a drag operation has begun. Used to suppress tooltip display during drag operations, as tooltips would interfere with drag feedback and user interaction.
|
private |
Used in conjunction with MOUSE_MOVEMENT_THRESHOLD to detect significant mouse movement. When movement exceeds the threshold, tooltip display is canceled to prevent tooltips from appearing during rapid cursor movement.
|
private |
This flag is updated by PointerEnter and PointerLeave events to maintain accurate state tracking. It's used to determine when tooltips should be scheduled for display and when they should be hidden.
|
private |
This flag prevents multiple tooltip display operations from being scheduled simultaneously. It's set to true when a tooltip display is queued and false when the operation completes or is canceled.
|
private |
This scheduled item can be paused or canceled when tooltip display needs to be interrupted due to user interaction changes. It's created when tooltip display is scheduled and cleared when the operation completes.
|
private |
This reference is obtained from the WindowFrameController during construction and provides access to the centralized tooltip display system. If the WindowFrameController is not available, tooltip functionality is disabled.
|
staticprivate |
This threshold prevents tooltips from being canceled by minor mouse movements such as hand tremor or slight adjustments. The value of 2 pixels provides a good balance between responsiveness and stability.
|
getprivate |
The delay in seconds before tooltips are displayed, or 0.5 seconds as fallback if WindowFrameController is not available.
This property provides dynamic access to the current tooltip delay setting, allowing tooltips to respect user preferences and configuration changes. The delay is automatically converted from milliseconds (WindowFrameController format) to seconds (Unity scheduler format).