50252: fix key events for printable but non-alphabetic keys. r=dr

This commit is contained in:
akkana%netscape.com 2000-09-18 19:50:50 +00:00
Родитель 8f52f8fd95
Коммит aa0919a0aa
1 изменённых файлов: 9 добавлений и 9 удалений

Просмотреть файл

@ -298,15 +298,15 @@ int nsPlatformToDOMKeyCode(GdkEventKey *aGEK)
PRUint32 nsConvertCharCodeToUnicode(GdkEventKey* aGEK) PRUint32 nsConvertCharCodeToUnicode(GdkEventKey* aGEK)
{ {
// For control chars, GDK sets string to be the actual ascii value.
// Map that to what nsKeyEvent wants, which currently --
// TEMPORARILY (the spec has changed and will be switched over
// when the tree opens for M11) --
// is the ascii for the actual event (e.g. 1 for control-a).
// This is only true for control chars; for alt chars, send the
// ascii for the key, i.e. a for alt-a.
if (aGEK->state & GDK_CONTROL_MASK) if (aGEK->state & GDK_CONTROL_MASK)
{ {
if (isprint(aGEK->string[0]) && !isalpha(aGEK->string[0]))
return aGEK->string[0];
// For alphabetic control chars, GDK sets string to be the
// actual ascii value; it doesn't do this for numeric or
// other printable characters.
// So we have to map back to the actual character.
if (aGEK->state & GDK_SHIFT_MASK) if (aGEK->state & GDK_SHIFT_MASK)
return aGEK->string[0] + 'A' - 1; return aGEK->string[0] + 'A' - 1;
else else
@ -404,8 +404,8 @@ void InitKeyPressEvent(GdkEventKey *aGEK,
anEvent.keyCode = nsPlatformToDOMKeyCode(aGEK); anEvent.keyCode = nsPlatformToDOMKeyCode(aGEK);
#if defined(DEBUG_akkana_not) || defined (DEBUG_ftang) #if defined(DEBUG_akkana_not) || defined (DEBUG_ftang)
printf("Key Press event: keyCode = 0x%x, char code = '%c'", printf("Key Press event: gtk string = '%s', keyCode = 0x%x, char code = '%c'",
anEvent.keyCode, anEvent.charCode); aGEK->string, anEvent.keyCode, anEvent.charCode);
if (anEvent.isShift) if (anEvent.isShift)
printf(" [shift]"); printf(" [shift]");
if (anEvent.isControl) if (anEvent.isControl)