过滤某个事件

This commit is contained in:
taynpg 2024-01-25 14:34:10 +08:00
parent 8a1306e49e
commit fc53babbb8
5 changed files with 35 additions and 6 deletions

View File

@ -16,7 +16,7 @@ find_package(wxWidgets REQUIRED COMPONENTS core base)
include(${wxWidgets_USE_FILE})
add_executable(wxWidgetStudy main.cpp)
add_executable(wxEvent event_01_exe.cpp src/event_01.cpp)
add_executable(wxEvent event_binary.cpp src/event_demo.cpp)
target_link_libraries(wxWidgetStudy PRIVATE ${wxWidgets_LIBRARIES})
target_link_libraries(wxEvent PRIVATE ${wxWidgets_LIBRARIES})

View File

@ -1,4 +0,0 @@
#include "src/event_01.h"
IMPLEMENT_APP(MyApp)
DECLARE_APP(MyApp)

4
event_binary.cpp Normal file
View File

@ -0,0 +1,4 @@
#include "src/event_demo.h"
IMPLEMENT_APP(MyApp)
DECLARE_APP(MyApp)

View File

@ -1,4 +1,4 @@
#include "event_01.h"
#include "event_demo.h"
BEGIN_EVENT_TABLE(MainFrame, wxFrame)
EVT_MENU(wxID_ABOUT, MainFrame::OnAbout)

View File

@ -37,6 +37,35 @@
访
*/
/*
wxWidgets事件处理系统实现了一些和C++
便
wxTextCtrl的新的类使EVT_KEY_DOWN事件映射宏
wxEvent::Skip函数来提示事件处理过程对于其中的
wxWidgets中Skip方法
"a""z""A""Z"
void MyTextCtrl::OnChar(wxKeyEvent& event)
{
if ( wxIsalpha(event.KeyCode()))
{
//这些按键在可以接受的范围,所以按照正常的流程处理
event.Skip();
}
else
{
// 这些事件不在我们可以接受的范围,所以我们不调用Skip函数
// 由于事件表已经匹配并且没有调用Skip函数,所以事件处理过程不会
// 再继续匹配别的事件表,而是认为事件处理已经结束
wxBell();
}
}
*/
class MyApp : public wxApp {
public:
virtual bool OnInit();