Changeset 106


Ignore:
Timestamp:
Jul 29, 2006, 3:56:44 PM (19 years ago)
Author:
dmik
Message:

Widgets: QTextEdit: Fixed: AltGr+key can produce valid characters in some kbd layouts (i.e. the German one) which we must not ignore.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/kernel/qapplication_pm.cpp

    r102 r106  
    12011201
    12021202        case WM_CHAR: {                 // keyboard event
    1203 //@@TODO (dmik): remove
    1204 //qDebug("WM_CHAR:  [%s]", widget->name());
     1203#if 0
     1204            qDebug( "WM_CHAR:  [%s]", widget->name() );
     1205#endif           
    12051206            QWidget *g = QWidget::keyboardGrabber();
    12061207            if ( g )
     
    12091210                widget = (QETWidget*)qApp->focusWidget();
    12101211            else if ( !widget )
    1211 //@@TODO (dmik): currently we don't use WinSetFocus(). what for? Qt seems
     1212/// @todo (dmik) currently we don't use WinSetFocus(). what for? Qt seems
    12121213//  to completely handle focus traversal itself.
    12131214//                    || widget->winId() == WinQueryFocus( HWND_DESKTOP ) ) // We faked the message to go to exactly that widget.
    12141215                widget = (QETWidget*)widget->topLevelWidget();
    12151216            if ( widget->isEnabled() ) {
    1216 //@@TODO (dmik): we should not pass WM_CHAR to the default window proc,
     1217/// @todo (dmik) we should not pass WM_CHAR to the default window proc,
    12171218//  otherwise it will come to us again through the widget parent (owner in PM)
    12181219//  if the widget is not top-level, and will be treated by translateKeyEvent()
     
    12281229        }
    12291230
    1230 //@@TODO (dmik): later
     1231/// @todo (dmik) later
    12311232//      case WM_APPCOMMAND:
    12321233//          {
     
    26632664
    26642665// when the compatibility mode is FALSE Qt/OS2 uses the following rule
    2665 // to calculate QKeyEvent::key() codes when the the alpha-numeric key is
     2666// to calculate QKeyEvent::key() codes when an alpha-numeric key is
    26662667// pressed: key code is the ASCII (Latin 1) character code of that key as if
    26672668// there were no any keyboard modifiers (CTRL, SHIFT, ALT) pressed, with the
     
    26692670// when the compatibility mode is TRUE Qt/OS2 behaves mostly like Qt/Win32.
    26702671Q_EXPORT bool qt_kbd_compatibility = TRUE;
    2671 //@@TODO (dmik): currentlly, qt_kbd_compatibility is TRUE because
     2672
     2673/// @todo (dmik) currentlly, qt_kbd_compatibility is TRUE because
    26722674//  qt_scan2Ascii function below is not well implemented yet (in particular,
    2673 //  it uses the 850 code page that can be not available on some systems...)
     2675//  it uses the 850 code page that may not be available on some systems...).
     2676//  Once we find a way to translate scans to US ASCII regardless of the current
     2677//  code page and/or NLS state (keyboard layout), qt_kbd_compatibility may be
     2678//  set to FALSE. This, in particular, will enable more correct handling of
     2679//  Alt+letter combinations when the keyboard is in the NLS state:
     2680//  QKeyEvent::key() will return a non-null Qt::Key_XXX code corresponding to
     2681//  the ASCII code of a pressed key, which in turn will let Qt process latin
     2682//  Alt+letter shortcuts in the NLS keyboard mode together with Alt+NLS_letter
     2683//  shortcuts  (nice feature imho). Note that Alt+NLS_letter shortcuts are
     2684//  correctly processed in any case.
    26742685
    26752686// cache table to store Qt::Key_... values for 256 hardware scancodes
     
    27132724
    27142725// translates WM_CHAR to Qt::Key_..., ascii, state and text
    2715 void translateKeyCode(
    2716     CHRMSG &chm, int &code, int &ascii, int &state, QString &text
    2717 ) {
     2726static void translateKeyCode( CHRMSG &chm, int &code, int &ascii, int &state,
     2727                              QString &text )
     2728{
    27182729    if ( chm.fs & KC_SHIFT )
    27192730        state |= Qt::ShiftButton;
     
    27932804                    break;
    27942805                default:
     2806                    // break if qt_kbd_compatibility = TRUE to avoid using
     2807                    // qt_scan2Ascii(), see comments to qt_kbd_compatibility
    27952808                    if ( qt_kbd_compatibility ) break;
    27962809                    // deduce Qt::Key... from scancode
     
    28742887    if ( ascii > 0x7F ) ascii = 0;
    28752888    if ( ch )
    2876 //@@TODO (dmik): later: optimize by using UniUconvToUcs directly
    28772889        text = QString::fromLocal8Bit( (char*)&ch, 1 );
    28782890}
    2879 
    2880 //@@TODO (dmik): do we need to export this also? I don't see that it is used
    2881 //  anywhere in Qt/Win32...
    2882 //Q_EXPORT int qt_translateKeyCode(int key)
    2883 //{
    2884 //    return translateKeyCode(key);
    2885 //}
    28862891
    28872892struct KeyRec {
     
    29442949}
    29452950
    2946 static void store_key_rec(
    2947     unsigned char scan, int code, int ascii, const QString& text
    2948 ) {
     2951static void store_key_rec( unsigned char scan, int code, int ascii,
     2952                           const QString& text )
     2953{
    29492954    if ( nrecs == maxrecs ) {
    29502955#if defined(QT_CHECK_RANGE)
     
    29973002                        // remove the Key_Alt from the buffer (otherwise we will
    29983003                        // not get the next "Alt pressed" event because the
    2999                         // "Alt depressed" event, that must preceed it, well be
     3004                        // "Alt depressed" event, that must preceed it, will be
    30003005                        // eaten by the system)
    3001 //@@TODO (dmik): do the same for other global keys (ALT+TAB, ALT+ESC, CTRL+ESC)
     3006                        find_key_rec( Qt::Key_Alt, TRUE );
     3007/// @todo (dmik) do the same for other global keys (ALT+TAB, ALT+ESC, CTRL+ESC)
    30023008//  by handling this situation when we obtain/loose focus)
    3003                         find_key_rec( Qt::Key_Alt, TRUE );
     3009/// @todo (dmik) update: I don't actually think the above should be done, because
     3010//  it will not solve the problem of stuck modifier keys in general (there may be
     3011//  other combinations stolen by the system or other apps). More over, I guess
     3012//  that find_key_rec() above should also be removed to get identical behavior for
     3013//  all stolen keys. This will allow to solve the problem on the Qt application
     3014//  level if needed (and even in a platform-independent manner).
    30043015                    }
    30053016                    return TRUE;
     
    30203031            if ( rec->code < Key_Shift || rec->code > Key_ScrollLock ) {
    30213032                k0 = sendKeyEvent( QEvent::KeyRelease, rec->code, rec->ascii,
    3022                                    state, grab, rec->text, TRUE);
     3033                                   state, grab, rec->text, TRUE );
    30233034                k1 = sendKeyEvent( QEvent::KeyPress, rec->code, rec->ascii,
    3024                                    state, grab, rec->text, TRUE);
     3035                                   state, grab, rec->text, TRUE );
    30253036            }
    30263037        } else {
     
    30403051        } else {
    30413052            k0 = sendKeyEvent( QEvent::KeyRelease, rec->code, rec->ascii,
    3042                                 state, grab, rec->text);
     3053                                state, grab, rec->text );
    30433054
    30443055            // keyboard context menu event
     
    30483059    }
    30493060
    3050 //@@TODO (dmik): remove
    3051 //    qDebug("WM_CHAR: RESULT = %d", (k0 || k1));
     3061#if 0   
     3062    qDebug("WM_CHAR: RESULT = %d", (k0 || k1));
     3063#endif   
    30523064    return k0 || k1;
    30533065}
  • TabularUnified trunk/src/widgets/qtextedit.cpp

    r8 r106  
    13761376            if ( e->text().length() &&
    13771377                ( !( e->state() & ControlButton ) &&
    1378 #ifndef Q_OS_MACX
     1378#if !defined(Q_OS_MACX) && !defined(Q_OS_OS2)
     1379                  // AltGr+key can produce valid characters in some kbd layouts
     1380                  // (i.e. the German one) which we must not ignore
    13791381                  !( e->state() & AltButton ) &&
    13801382#endif
    13811383                  !( e->state() & MetaButton ) ||
     1384                  // Note (dmik): the below line is possibly a typo because it's
     1385                  // equivalent to just (e->state() & ControlButton) which obviously
     1386                  // contradicts !( e->state() & ControlButton ) above. Anyway,
     1387                  // as a result, Ctrl+key are successfully handled by QTextEdit on
     1388                  // all platforms (because of the || operator), unless assigned
     1389                  // as hot keys (shortcuts).
    13821390                 ( ( (e->state()&ControlButton) | AltButton ) == (ControlButton|AltButton) ) ) &&
    13831391                 ( !e->ascii() || e->ascii() >= 32 || e->text() == "\t" ) ) {
Note: See TracChangeset for help on using the changeset viewer.