[QScintilla] Mouse event filter for QsciScintilla

Phil Thompson phil at riverbankcomputing.com
Mon Nov 13 22:15:57 GMT 2017


On 13 Nov 2017, at 8:02 pm, VA <dev+pyqt at indigo.re> 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?

Phil

-------------- next part --------------
A non-text attachment was scrubbed...
Name: events.py
Type: text/x-python-script
Size: 501 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/qscintilla/attachments/20171113/eacf910d/attachment.bin>


More information about the QScintilla mailing list