-----BEGIN PGP SIGNED MESSAGE-----

On Sonntag, 8. Dezember 2002 05:30, John Levon wrote:
> Here's the version which masks out shift

John, I have now a version which works with latin-2 also.
Don't know, why QString::text() is not working, while QString::ascii() is.

It patches only QLyXKeySym::set() and QLyXKeySym::getSymbolName().
All other changes are yours.
        Kornel
- -- 
Kornel Benko
[EMAIL PROTECTED]
-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.8

iQCVAwUBPfN5MbewfbDGmeqhAQHdVwP+Obn2tkwy6BXcgK+c1v+YjUFacEVOMGjG
+w6OtMfsdOSrnWoX9tiuIIT6knoTL35co6rV5wzwohin8WahU/gX5MWaCMp41Ul3
nHgeHVHKq3/h7x6OlVRN+DpzdOGwLF7cxE/gI8HfTh74IIE2YJ9ojhpeZMw0rUYQ
zH2DuY3JK3g=
=3xua
-----END PGP SIGNATURE-----
Index: QLyXKeySym.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/QLyXKeySym.C,v
retrieving revision 1.10
diff -u -r1.10 QLyXKeySym.C
--- QLyXKeySym.C	2002/10/20 01:48:27	1.10
+++ QLyXKeySym.C	2002/12/08 16:51:53
@@ -33,7 +33,29 @@
 void QLyXKeySym::set(QKeyEvent * ev)
 {
 	key_ = ev->key();
-	text_ = ev->text();
+	{
+	    QString s = ev->text();
+	    lyxerr[Debug::KEY] << " unicode of key is";
+	    for (int i = 0; i < s.length(); i++) {
+		QChar a = s.ref(i);
+		lyxerr[Debug::KEY] << " " << (int) a ;
+	    }
+	    if (s.length() > 0) {
+	    	lyxerr[Debug::KEY] << " ascii == " << ev->ascii();
+	    }
+	    lyxerr[Debug::KEY] << endl;
+	    if ((s.length() == 1) && ( key_ == 65535)) {
+		if ((int) s.ref(0) == 0) {
+		    char xx[2];
+		    xx[0] = ev->ascii();
+		    xx[1] = '\0';
+		    s = xx;
+		    key_ = 0;
+		}
+	    }
+	    text_ = s;
+	}
+	lyxerr[Debug::KEY] << "Setting key to " << key_ << ", " <<  text_.latin1() << endl;
 }
 
 
@@ -41,19 +63,23 @@
 {
 	key_ = string_to_qkey(symbolname);
 	text_ = symbolname.c_str();
-	lyxerr[Debug::KEY] << "Init key to " << key_ << ", " << text_ << endl;
+	lyxerr[Debug::KEY] << "Init key to " << key_ << ", " << text_.latin1() << endl;
 }
 
 
 bool QLyXKeySym::isOK() const
 {
-	return ! key_ == 0;
+	bool const ok(!(text_.isEmpty() && key_ == Qt::Key_unknown));
+	lyxerr[Debug::KEY] << "isOK is " << ok << endl;
+	return ok;
 }
-
 
+ 
 bool QLyXKeySym::isModifier() const
 {
-	return q_is_modifier(key_);
+	bool const mod(q_is_modifier(key_));
+	lyxerr[Debug::KEY] << "isMod is " << mod << endl;
+	return mod;
 }
 
 
@@ -63,7 +89,10 @@
 
 	if (sym.empty()) {
 		lyxerr[Debug::KEY] << "sym empty in getSymbolName()" << endl;
-		sym = text_.latin1();
+		if (text_.length() > 0)
+		    sym = text_.latin1();
+		else
+		    sym = "none";
 	}
 	lyxerr[Debug::KEY] << "getSymbolName() -> " << sym << endl;
 	return sym;
@@ -77,6 +106,20 @@
 }
 
 
+bool QLyXKeySym::isText() const
+{
+	if (text_.isEmpty()) {
+		lyxerr[Debug::KEY] << "text_ empty, isText() == false" << endl;
+		return false;
+	}
+
+	QChar const c(text_[0]);
+	lyxerr[Debug::KEY] << "isText for key " << key_ 
+		<< " isPrint is " << c.isPrint() << endl;
+	return c.isPrint();
+}
+
+ 
 bool operator==(LyXKeySym const & k1, LyXKeySym const & k2)
 {
 	// note we ignore text_ here (non-strict ==), because

Reply via email to