如何处理 WXWIDGETS 中父窗口的鼠标事件

how to handle mouse events of parent window in wxwidgets

本文关键字:窗口 鼠标 事件 WXWIDGETS 何处理 处理      更新时间:2023-10-16

>我有一个父窗口,上面有一个子窗口,如何处理从子窗口到父窗口的鼠标事件。

这是我的代码:

   //parent class
   IMPLEMENT_DYNAMIC_CLASS(MWParent, wxPanel)
    BEGIN_EVENT_TABLE(MWParent, wxPanel) 
    EVT_LEFT_DCLICK(MWParent::OnMouseLeftDClick)
    EVT_RIGHT_DOWN(MWParent::OnMouseRightclick)
    END_EVENT_TABLE()
    MWParent::MWParent()
    {
    }
    MWParent::~MWParent()
    {
    }
    MWParent::MWParent( wxWindow *win , long id ):wxPanel( win , id ){
            MWChild *obj = new MWChild(this);
    }
   //child class
    IMPLEMENT_DYNAMIC_CLASS(MWChild, wxPanel)
    BEGIN_EVENT_TABLE(MWChild, wxPanel) 
    END_EVENT_TABLE()
    MWChild::MWChild()
    {
    }
    MWChild::~MWChild()
    {
    }
    MWChild::MWChild( wxWindow *win , long id ):wxPanel( win , id ){

}

使用 Bind() 将子事件连接到任何其他窗口(可能是父窗口)中的处理程序。

有关详细信息,请参阅事件处理概述。