Skip to content

Conversation

@miroiu
Copy link
Owner

@miroiu miroiu commented Dec 7, 2024

📝 Description of the Change

Redesigned input processing and state management to support multiple input devices, and simplified handling complex input scenarios while ensuring extensibility for future enhancements.

Key classes and interfaces:

  • InputProcessor - a central component for registering and processing input events
  • IInputHandler - an interface for processing input events dispatched by the InputProcessor
  • InputElementState - a base class for managing element-specific input states; it provides hooks for common input events, such as mouse and keyboard interactions
  • DragState - a specialized class for implementing click-and-drag operations; it supports customization for starting and ending operations and context-menu handling
  • InputElementStateStack - manages a stack of element states, allowing for easier state transitions and operations on elements

The NodifyEditor, ItemContainer, and Connector elements can now handle custom input events through the InputProcessor. To process custom input events:

  1. Define a custom event type inheriting from InputEventArgs.
  2. Create a subclass of NodifyEditor and call InputProcessor.Process with your custom event type.
  3. Register a custom IInputHandler using InputProcessor.AddInputHandler or derive from an existing input handler.

When deriving from InputElementState, override the OnEvent method to handle specific input events for the element.

For click-and-drag operations, derive from DragState and override IsInputEventPressed and IsInputEventReleased to define conditions for starting and ending drag operations.

Alternatively, extend a more specialized handler (e.g., EditorPanningState) and override its OnEvent method. Ensure you remove the existing handler using InputProcessor.RemoveHandler before adding your derived implementation to avoid conflicts.

Related: #146

🐛 Possible Drawbacks

I don't know.

@miroiu miroiu marked this pull request as ready for review December 10, 2024 21:55
@miroiu miroiu merged commit 243867c into master Dec 11, 2024
4 checks passed
@miroiu miroiu deleted the feature/146-input-system branch December 11, 2024 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants