tvjsx / trading-vue-js

💹 Hackable charting lib for traders. You can draw literally ANYTHING on top of candlestick charts. [Not Maintained]
https://tvjsx.github.io/trading-vue-demo/
MIT License
2.07k stars 628 forks source link

Event "object-selected" should return the object #267

Open leoplaw opened 2 years ago

leoplaw commented 2 years ago

https://github.com/tvjsx/trading-vue-js/blob/e881bdb5c3ec3b890d21e3059cb6b3ef85a47432/src/components/primitives/pin.js#L157

Event object-selected should return the object so listener can identify which object emitted it.

this.comp.$emit('object-selected', this)

I tried hacking this into the code, but it does not seem to work. So perhaps it is the wrong place?

leoplaw commented 2 years ago

tool-selectedevent returns the originating tool which emitted the event. object-selected does not.

On the object-selected event, the chart.data.selectedis not populated, so the following is not possible: this.chart.get(this.chart.data.selected)

So far the method that does work is to use a watcher.

    'chart.data.selected': function(newValue, oldValue) {
      if (newValue) {
        console.log("TVJS: selected:",newValue)
        const selected = this.chart.get(newValue)
        console.log("TVJS: Object Selected:",selected)
      }
    }