Fix toolbox hotkey chart selection and toolbox resize display bug (#267)

This commit is contained in:
louisnw
2024-02-24 13:01:37 +00:00
parent e199e54c7a
commit 745c14bb7f
3 changed files with 21 additions and 8 deletions

View File

@ -225,8 +225,6 @@ function makeSearchBox(chart) {
chart.chart.subscribeCrosshairMove((param) => {
if (param.point) yPrice = param.point.y;
})
window.selectedChart = chart
chart.wrapper.addEventListener('mouseover', (event) => window.selectedChart = chart)
chart.commandFunctions.push((event) => {
if (selectedChart !== chart) return false
if (searchWindow.style.display === 'none') {

View File

@ -70,6 +70,10 @@ if (!window.Chart) {
if (this.commandFunctions[i](event)) break
}
})
window.selectedChart = this
this.wrapper.addEventListener('mouseover', (e) => window.selectedChart = this)
if (!autoSize) return
window.addEventListener('resize', () => this.reSize())
}
@ -78,15 +82,21 @@ if (!window.Chart) {
this.chart.resize(window.innerWidth * this.scale.width, (window.innerHeight * this.scale.height) - topBarOffset)
this.wrapper.style.width = `${100 * this.scale.width}%`
this.wrapper.style.height = `${100 * this.scale.height}%`
if (this.legend) {
if (this.scale.height === 0 || this.scale.width === 0) {
this.legend.div.style.display = 'none'
if (this.toolBox) {
this.toolBox.elem.style.display = 'none'
}
}
else {
this.legend.div.style.display = 'flex'
if (this.toolBox) {
this.toolBox.elem.style.display = 'flex'
}
}
}
makeCandlestickSeries() {
this.markers = []

View File

@ -117,6 +117,11 @@ if (!window.ToolBox) {
this.chart.activeIcon.action(true)
})
this.chart.commandFunctions.push((event) => {
if (this.chart !== window.selectedChart) {
return
}
if (event.altKey && event.code === keyCmd) {
event.preventDefault()
if (this.chart.activeIcon) {