Skip to content

Conversation

@SlicedSilver
Copy link
Contributor

@SlicedSilver SlicedSilver commented Aug 6, 2025

Type of PR: enhancement

To do:

  • Tests
  • Documentation update

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.44kb to the bundle size.

@SlicedSilver SlicedSilver self-assigned this Aug 6, 2025
@SlicedSilver SlicedSilver added enhancement Feature requests, and general improvements. polish Very minor behavior improvement that users will enjoy. labels Aug 6, 2025
@SlicedSilver SlicedSilver requested a review from Copilot August 6, 2025 14:44
Copy link

Copilot AI left a 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 IAxisApi with 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();
Copy link

Copilot AI Aug 6, 2025

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.

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();
}

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Aug 6, 2025

size-limit report 📦

Path Size
ESM 46.26 KB (+0.74% 🔺)
ESM createChart 38.03 KB (+1.15% 🔺)
ESM createChartEx 36.76 KB (+1.04% 🔺)
ESM createYieldCurveChart 38.25 KB (+1.08% 🔺)
ESM createOptionsChart 36.95 KB (+1.07% 🔺)
Standalone-ESM 47.72 KB (+0.77% 🔺)
Standalone 47.68 KB (+0.89% 🔺)
Plugin: Text Watermark 1.92 KB (+0.52% 🔺)
Plugin: Image Watermark 1.72 KB (-0.74% 🔽)
Plugin: Series Markers 4.32 KB (-0.16% 🔽)
Series: LineSeries 2.59 KB (+0.42% 🔺)
Series: BaselineSeries 3.23 KB (-0.04% 🔽)
Series: AreaSeries 3.15 KB (-0.31% 🔽)
Series: BarSeries 2.19 KB (+0.23% 🔺)
Series: CandlestickSeries 2.48 KB (-0.4% 🔽)
Series: HistogramSeries 2.23 KB (+0.09% 🔺)
Plugin: UpDownMarkersPrimitive 2.42 KB (+0.61% 🔺)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature requests, and general improvements. polish Very minor behavior improvement that users will enjoy.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants