Redesigned state management #170
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📝 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 eventsIInputHandler- an interface for processing input events dispatched by theInputProcessorInputElementState- a base class for managing element-specific input states; it provides hooks for common input events, such as mouse and keyboard interactionsDragState- a specialized class for implementing click-and-drag operations; it supports customization for starting and ending operations and context-menu handlingInputElementStateStack- manages a stack of element states, allowing for easier state transitions and operations on elementsThe
NodifyEditor,ItemContainer, andConnectorelements can now handle custom input events through theInputProcessor. To process custom input events:NodifyEditorand callInputProcessor.Processwith your custom event type.IInputHandlerusingInputProcessor.AddInputHandleror derive from an existing input handler.When deriving from
InputElementState, override theOnEventmethod to handle specific input events for the element.For click-and-drag operations, derive from
DragStateand overrideIsInputEventPressedandIsInputEventReleasedto define conditions for starting and ending drag operations.Alternatively, extend a more specialized handler (e.g.,
EditorPanningState) and override itsOnEventmethod. Ensure you remove the existing handler usingInputProcessor.RemoveHandlerbefore adding your derived implementation to avoid conflicts.Related: #146
🐛 Possible Drawbacks
I don't know.