|
Window Framework v1.2.4
Window Framework for Unity UI Toolkit
|
A configurable mouse manipulator that provides flexible click event handling with customizable activation criteria. More...
Public Member Functions | |
| ClickActivatorConfigurable (Action action=null) | |
| Initializes a new ClickActivatorConfigurable with default settings (single left-click). | |
| ClickActivatorConfigurable (int clickCount, Action action) | |
| Initializes a new ClickActivatorConfigurable with a specific click count and default left mouse button. | |
| ClickActivatorConfigurable (int clickCount, MouseButton button, Action action) | |
| Initializes a new ClickActivatorConfigurable with full customization of click count, mouse button, and action. | |
Protected Member Functions | |
| override void | RegisterCallbacksOnTarget () |
| Registers the mouse down event callback on the target element. | |
| override void | UnregisterCallbacksFromTarget () |
| Unregisters the mouse down event callback from the target element during cleanup. | |
Private Member Functions | |
| void | Init (int clickCount, MouseButton button, Action action) |
| Performs common initialization logic for all constructor overloads. | |
| void | OnMouseDown (MouseDownEvent evt) |
| Handles mouse down events and executes the configured action when activation criteria are met. | |
Private Attributes | |
| Action | _action |
| The action delegate that will be executed when the configured click pattern is detected. | |
This manipulator simplifies the process of creating custom click behaviors by providing a streamlined alternative to manually configuring Clickable manipulators with activation filters. It offers flexible configuration options for different click patterns and mouse buttons.
Key Features:
Advantages over Manual Clickable Setup:
This manipulator is particularly useful for creating custom UI interactions that require specific click patterns or non-standard mouse button behaviors that go beyond basic button click handling.
| GWG.WindowFramework.Manipulators.ClickActivatorConfigurable.ClickActivatorConfigurable | ( | Action | action = null | ) |
| action | The action to execute when a click is detected. Can be null. |
This constructor provides the simplest initialization for standard left-click behavior. It's equivalent to creating a basic Clickable but with the added benefit of consistent initialization patterns and automatic event handling.
Default Configuration:
This constructor is ideal for simple UI interactions where standard click behavior is desired without additional complexity.
| GWG.WindowFramework.Manipulators.ClickActivatorConfigurable.ClickActivatorConfigurable | ( | int | clickCount, |
| Action | action ) |
| clickCount | The number of consecutive clicks required to activate the action |
| action | The action to execute when the click pattern is detected |
This constructor allows customization of the click count while maintaining the standard left mouse button behavior. It's particularly useful for implementing double-click, triple-click, or other multi-click interactions.
Click Count Behavior:
The timing for multi-click detection is handled by Unity's UI Toolkit and follows system double-click timing settings. Clicks must occur within the system-defined time window to be recognized as part of the same click sequence.
| GWG.WindowFramework.Manipulators.ClickActivatorConfigurable.ClickActivatorConfigurable | ( | int | clickCount, |
| MouseButton | button, | ||
| Action | action ) |
| clickCount | The number of consecutive clicks required to activate the action |
| button | The specific mouse button that triggers the action |
| action | The action to execute when the click pattern is detected |
This constructor provides complete control over click activation behavior, allowing customization of both the click pattern and the mouse button used for activation. It's the most flexible constructor and supports advanced interaction scenarios.
Mouse Button Options:
This constructor enables the creation of sophisticated interaction patterns that can differentiate between different mouse buttons and click frequencies, allowing for rich, context-sensitive user interfaces.
|
private |
| clickCount | The number of consecutive clicks required for activation |
| button | The mouse button that triggers the manipulator |
| action | The action to execute when activation criteria are met |
This private method centralizes the initialization logic to ensure consistent setup across all constructor overloads. It performs two primary operations:
Action Storage:
Activation Filter Configuration:
This centralized approach prevents code duplication and ensures that all instances of the manipulator are configured consistently regardless of which constructor is used.
|
private |
| evt | The mouse down event data containing button information, position, and click count |
This method is the core event handler that processes mouse input and determines whether to execute the configured action. It performs validation, action execution, and event management in a coordinated sequence:
Validation Process:
Action Execution:
Event Management:
The method provides reliable click detection with proper isolation from other event handlers, making it suitable for complex UI scenarios with multiple overlapping interaction patterns.
|
protected |
This method is automatically called by Unity's UI Toolkit when the manipulator is added to a target element. It establishes the event handling chain that enables the manipulator to respond to mouse input.
Event Registration:
The MouseDownEvent is chosen because it provides the most reliable detection of click events, including proper click count tracking and button identification. The manipulator's activation filters ensure that only relevant events trigger the configured action.
|
protected |
This method is automatically called by Unity's UI Toolkit when the manipulator is removed from a target element or when the element is destroyed. It ensures proper cleanup of event handlers to prevent memory leaks and orphaned callbacks.
Cleanup Operations:
Proper unregistration is essential for maintaining application performance and preventing unexpected behavior when elements are dynamically created and destroyed during the application lifecycle.
|
private |
This action is invoked when the manipulator detects a mouse click event that matches the configured activation criteria (button type and click count). The action can be null, in which case no operation is performed when the click is detected.
The action is executed immediately when the click pattern is recognized, and event propagation is automatically stopped to prevent other handlers from processing the same mouse event.