add simple mouse events for price and time scales#1942
Draft
SlicedSilver wants to merge 3 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds mouse and touch event support to both time and price scale axis widgets, enabling plugin developers to respond to click and mouse movement events on the axes.
- Introduces a new interface
IAxisApiwith event subscription methods for axis interactions - Implements mouse event handling infrastructure in axis widgets with proper event delegation
- Extends existing API classes to expose the new axis event functionality
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/model/axis-widget.ts | Defines core interfaces for axis mouse events and event parameter suppliers |
| src/model/axis-model.ts | Implements base AxisApi class with event handling infrastructure and parameter conversion |
| src/gui/axis-mouse-event-helpers.ts | Provides utility functions for firing mouse event delegates with proper parameter mapping |
| src/gui/time-axis-widget.ts | Adds mouse event handling to time axis widget with delegate firing and cursor override support |
| src/gui/price-axis-widget.ts | Extends price axis widget with mouse events, inheriting from AxisApi and implementing event methods |
| src/gui/chart-widget.ts | Adds method to retrieve price axis widget instances for event subscription |
| src/api/iaxis-api.ts | Defines public interface for axis event subscription and cursor override methods |
| src/api/time-scale-api.ts | Extends time scale API with axis event methods by inheriting from AxisApi |
| src/api/price-scale-api.ts | Implements axis event methods in price scale API by delegating to underlying widget |
| src/api/itime-scale-api.ts | Extends interface to include IAxisApi methods |
| src/api/iprice-scale-api.ts | Extends interface to include IAxisApi methods |
Comment on lines
+52
to
+55
| widget.clicked().unsubscribeAll(this); | ||
| this._clickedDelegate.destroy(); | ||
| widget.mouseMoved().unsubscribeAll(this); | ||
| this._movedDelegate.destroy(); |
There was a problem hiding this comment.
The delegate is destroyed before unsubscribing from mouseMoved events. If mouseMoved().unsubscribeAll() fails, the _movedDelegate.destroy() on line 55 won't be called, leading to a resource leak.
Suggested change
| widget.clicked().unsubscribeAll(this); | |
| this._clickedDelegate.destroy(); | |
| widget.mouseMoved().unsubscribeAll(this); | |
| this._movedDelegate.destroy(); | |
| try { | |
| widget.clicked().unsubscribeAll(this); | |
| widget.mouseMoved().unsubscribeAll(this); | |
| } finally { | |
| this._clickedDelegate.destroy(); | |
| this._movedDelegate.destroy(); | |
| } |
size-limit report 📦
|
Introduces end-to-end tests for mouse interactions on the price scale and time scale. Tests verify that click and mouse move event handlers are invoked the expected number of times for both scales.
|
please continue this enhancement |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Type of PR: enhancement
To do:
Overview of change:
Adds simple mouse (and touch) event handlers for movement and clicking on the price and time scales. These could be useful for plugin developers.
Adds about
0.44kbto the bundle size.