Uggh, don't override click handler on view; pg has it's own mouse events..

fsp_feeds
Tyler Goodlet 2021-08-13 13:49:07 -04:00
parent f2376f90ad
commit c37ce664f5
1 changed files with 20 additions and 12 deletions

View File

@ -23,6 +23,7 @@ import time
from typing import Optional, Callable from typing import Optional, Callable
import pyqtgraph as pg import pyqtgraph as pg
from pyqtgraph.GraphicsScene import mouseEvents
from PyQt5.QtWidgets import QGraphicsSceneMouseEvent as gs_mouse from PyQt5.QtWidgets import QGraphicsSceneMouseEvent as gs_mouse
from PyQt5.QtCore import Qt, QEvent from PyQt5.QtCore import Qt, QEvent
from pyqtgraph import ViewBox, Point, QtCore from pyqtgraph import ViewBox, Point, QtCore
@ -250,17 +251,24 @@ async def handle_viewmode_mouse(
async for msg in recv_chan: async for msg in recv_chan:
button = msg.button button = msg.button
# pos = ev.pos()
if button == QtCore.Qt.RightButton and view.menuEnabled(): # XXX: ugggh ``pyqtgraph`` has its own mouse events..
# ev.accept() # so we can't overried this easily.
view.raiseContextMenu(msg.event) # it's going to take probably some decent
# reworking of the mouseClickEvent() handler.
elif button == QtCore.Qt.LeftButton: # if button == QtCore.Qt.RightButton and view.menuEnabled():
# event = mouseEvents.MouseClickEvent(msg.event)
# # event.accept()
# view.raiseContextMenu(event)
if (
view.order_mode and
button == QtCore.Qt.LeftButton
):
# when in order mode, submit execution # when in order mode, submit execution
if view.order_mode: # msg.event.accept()
# ev.accept() view.mode.submit_order()
view.mode.submit_order()
class ChartView(ViewBox): class ChartView(ViewBox):
@ -515,10 +523,10 @@ class ChartView(ViewBox):
self.scaleBy(x=x, y=y, center=center) self.scaleBy(x=x, y=y, center=center)
self.sigRangeChangedManually.emit(self.state['mouseEnabled']) self.sigRangeChangedManually.emit(self.state['mouseEnabled'])
def mouseClickEvent(self, event: QtCore.QEvent) -> None: # def mouseClickEvent(self, event: QtCore.QEvent) -> None:
'''This routine is rerouted to an async handler. # '''This routine is rerouted to an async handler.
''' # '''
pass # pass
def keyReleaseEvent(self, event: QtCore.QEvent) -> None: def keyReleaseEvent(self, event: QtCore.QEvent) -> None:
'''This routine is rerouted to an async handler. '''This routine is rerouted to an async handler.