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) => { chart.chart.subscribeCrosshairMove((param) => {
if (param.point) yPrice = param.point.y; if (param.point) yPrice = param.point.y;
}) })
window.selectedChart = chart
chart.wrapper.addEventListener('mouseover', (event) => window.selectedChart = chart)
chart.commandFunctions.push((event) => { chart.commandFunctions.push((event) => {
if (selectedChart !== chart) return false if (selectedChart !== chart) return false
if (searchWindow.style.display === 'none') { if (searchWindow.style.display === 'none') {

View File

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

View File

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