On 13 Nov 2017, at 11:32 pm, VA <[email protected]> wrote: > > Le 13/11/2017 à 23:15, Phil Thompson a écrit : >> On 13 Nov 2017, at 8:02 pm, VA <[email protected]> wrote: >>> >>> Le 13/11/2017 à 20:35, Phil Thompson a écrit : >>>> On 13/11/2017 18:41, VA wrote: >>>>> Le 13/11/2017 à 15:49, Phil Thompson a écrit : >>>>>> They do receive mouse press events. They are consumed (ie. accepted) and >>>>>> so do not make it to the event filter. >>>>> >>>>> Why don't they pass through the event filter as other events? >>>> That’s the way Qt works. If a mouse or key event is ignored (rather than >>>> accepted) then it will be passed to the filter. >>> >>> It's the opposite in Qt, the event filter is tested first, and if the >>> filter returns true, the event will not even reach the widget. >>> See the reference doc: >>> https://doc.qt.io/qt-5/qobject.html#installEventFilter >>> >>> And test this code where no text can be typed in a QtWidgets.QTextEdit (and >>> no mouse clicks) because an event filter filters events before the >>> QTextEdit receives them: >>> >>> class Filter(QObject): >>> def eventFilter(self, target, ev): >>> return True >>> >>> app = QApplication([]) >>> f = Filter() >>> sci = QTextEdit() >>> sci.installEventFilter(f) >>> sci.show() >>> app.exec_() >>> >>> So the events (like mouse press) sent to QsciScintilla should always go >>> through the event filter first, and if the filter returns true, the >>> QsciScintilla should not receive the event. >> So how do you explain the the behaviour of the attached? > > Well, I added a print in your sample code in the event() method, and it seems > with QsciScintilla, event() is called before eventFilter(), as you say. > However, if I replace QsciScintilla with a QLineEdit or a QPushButton, > eventFilter() is called before event(), so it cannot depend on > QEvent.ignore() being called with QLineEdit or QPushButton, since ignore() > has not been called yet. Additionaly, returning True in eventFilter() > prevents event() from being reached. > My opinion is that QLineEdit or QPushButton have the right behavior (at > least, it's consistent with the QObject docs I linked to earlier) > > Reading QCoreApplication::notify_helper > (https://code.woboq.org/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp.html#1159) > seems to confirm that event filters should be called before delivering an > event to an object.
Try installing the filter on the viewport(). Phil _______________________________________________ QScintilla mailing list [email protected] https://www.riverbankcomputing.com/mailman/listinfo/qscintilla
