天下

记录修行的印记

键盘事件的传递

class Q_GUI_EXPORT QWidget : public QObject, public QPaintDevice
{
protected:
    QWidget(QWidgetPrivate 
&d, QWidget* parent, Qt::WindowFlags f);
}

/*
\internal
*/
QWidget::QWidget(QWidgetPrivate 
&dd, QWidget* parent, Qt::WindowFlags f)
    : QObject(dd, 
0), QPaintDevice()
{
    Q_D(QWidget);
    QT_TRY {
        d
->init(parent, f);
    } QT_CATCH() {
        QWidgetExceptionCleaner::cleanup(
this, d_func());
        QT_RETHROW;
    }
}



//键盘事件的传递
extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
        
case WM_CHAR: {
            MSG msg1;
            
bool anyMsg = PeekMessage(&msg1, msg.hwnd, 00, PM_NOREMOVE);
            
if (anyMsg && msg1.message == WM_DEADCHAR) {
                result 
= true// consume event since there is a dead char next
                break;
            }
            QWidget 
*= QWidget::keyboardGrabber();
            
if (g && qt_get_tablet_widget() && hwnd == qt_get_tablet_widget()->winId()) {
                
// if we get an event for the internal tablet widget,
                
// then don't send it to the keyboard grabber, but
                
// send it to the widget itself (we don't use it right
                
// now, just in case).
                g = 0;
            }
            
if (g)
                widget 
= (QETWidget*)g;
            
else if (QApplication::activePopupWidget())  
                widget 
= (QETWidget*)QApplication::activePopupWidget()->focusWidget()
                       
? (QETWidget*)QApplication::activePopupWidget()->focusWidget()
                       : (QETWidget
*)QApplication::activePopupWidget();
            
else if (QApplication::focusWidget())  //这里条件为真
                widget = (QETWidget*)QApplication::focusWidget();  //得到具有输入焦点的widget
            else if (!widget || widget->internalWinId() == GetFocus()) // We faked the message to go to exactly that widget.
                widget = (QETWidget*)widget->window();
            
if (widget->isEnabled())
                result 
= sm_blockUserInput
                            
? true
                            : qt_keymapper_private()
->translateKeyEvent(widget, msg, g != 0);
            
break;
        }
    
//..
}


extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    
if (qt_is_translatable_mouse_event(message)) {
        
if (QApplication::activePopupWidget() != 0) { // in popup mode
            POINT curPos = msg.pt;
            QWidget
* w = QApplication::widgetAt(curPos.x, curPos.y);
            
if (w)
                widget 
= (QETWidget*)w;
        }

    
if (!qt_tabletChokeMouse) {
        result 
= widget->translateMouseEvent(msg); 
    }
    }
}

posted on 2013-07-04 12:02 天下 阅读(467) 评论(0)  编辑 收藏 引用 所属分类: QT


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2011年10月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

导航

统计

常用链接

留言簿(4)

随笔分类(378)

随笔档案(329)

链接

最新随笔

搜索

最新评论