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.

Dave


_______________________________________________
QScintilla mailing list
[email protected]
http://www.riverbankcomputing.com/mailman/listinfo/qscintilla

Reply via email to