highfestiva/finplot

[BUG] mouse callback does not differentiate between mouse buttons

simsam8 opened this issue · 1 comments

  • [ x ] I realize finplot is not a web lib. (Hint: it's native!)
  • [ x ] I've read the snippets and not found what I'm looking for.
  • [ x ] I've searched for any related issues and avoided creating a duplicate issue.
  • [ x ] I've updated finplot (pip install -U finplot).
  • [ x ] I've supplied the required data to run my code below.

Code to reproduce

import finplot as fplt
import yfinance

def left_mouse_click(x, y):
    print("left click")

def right_mouse_click(x, y):
    print("right click")

def middle_mouse_click(x, y):
    print("middle click")

df = yfinance.download('AAPL')
fplt.candlestick_ochl(df[['Open', 'Close', 'High', 'Low']])

fplt.set_mouse_callback(left_mouse_click, when="lclick")
fplt.set_mouse_callback(right_mouse_click, when="rclick")
fplt.set_mouse_callback(middle_mouse_click, when="mclick")

fplt.show()

Describe the bug

set_mouse_callback function uses the same callback function for all mouse buttons.

Expected behavior

Different callback function depending on which mouse button was clicked.

Reproducible in:

OS: Windows 11
finplot version: 1.9.3
pyqtgraph version: 0.13.3
pyqt version: 6.4.2

Realized this was added in commit 464fbbc.