[QScintilla] Command modifier problems on Mac OS X
Phil Thompson
phil at riverbankcomputing.com
Wed May 6 18:00:28 BST 2009
On Sun, 3 May 2009 21:45:35 -0500, David Hess <dhess at fishsoftware.com>
wrote:
> I'm having trouble with QScintilla accepting Command keystrokes such
> as Command-C, Command-X, etc.
>
> My system looks like:
> QScintilla 2.3.2
> PyQt4 4.4.4
> Qt 4.4.3
> Python 2.5.1
> Mac OS X 10.5.6
>
> The following works around the problem somewhat (all letter based
> Command combinations work).
>
> -----
> import string
>
> from PyQt4.QtCore import Qt
> from PyQt4.QtCore import QString
> from PyQt4.QtGui import QKeyEvent
> from PyQt4.Qsci import QsciScintilla
>
> class ViewerQsciScintilla(QsciScintilla):
> def keyPressEvent(self, event):
> if event.text() == "" and \
> event.count() == 1 and \
> int(event.modifiers()) != 0 and \
> event.key() >= Qt.Key_A and \
> event.key() <= Qt.Key_Z:
> new_text = QString(string.ascii_lowercase[event.key() -
> Qt.Key_A])
> else:
> new_text = event.text()
>
> new_event = QKeyEvent(event.type(), event.key(),
> event.modifiers(), new_text, event.isAutoRepeat(), event.count())
> QsciScintilla.keyPressEvent(self, new_event)
>
> if new_event.isAccepted():
> event.accept()
> -----
>
> The root of the problem appears to be that
> QsciScintillaBase::keyPressEvent expects event.text() to be set when a
> Command modifier is used and it's ending up a zero length string on my
> Mac.
>
> Would be happy to work with someone to produce a real bug fix.
Exactly what problem are you having? Does Command-A select all the text?
The event handler effectively ignores events like the press of the Command
key but passes on the subsequent press of the A key (with a flag set saying
the Command modifier is in effect).
Phil
More information about the QScintilla
mailing list