-
Notifications
You must be signed in to change notification settings - Fork 2.1k
add simple mouse events for price and time scales #1942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
| widget.clicked().unsubscribeAll(this); | ||
| this._clickedDelegate.destroy(); | ||
| widget.mouseMoved().unsubscribeAll(this); | ||
| this._movedDelegate.destroy(); |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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.
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.