diff --git a/.gitignore b/.gitignore index 014630f..76dc72e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ _temp/ _bin/ temp/ bin/ -.vs/ \ No newline at end of file +.vs/ +demo/* +*.lib \ No newline at end of file diff --git a/demo/Adminstor/Adminstor/mainForm.cpp b/demo/Adminstor/Adminstor/mainForm.cpp index c1a6689..b575d74 100644 --- a/demo/Adminstor/Adminstor/mainForm.cpp +++ b/demo/Adminstor/Adminstor/mainForm.cpp @@ -8,26 +8,20 @@ void mainForm::OnNotify(Control* sender, EventArgs& args) Event eventType = args.EventType; // 事件类型 // 针对管理界面的表格控件 - if (btnName == "tableViewAdmin") { - switch (eventType) - { - case 8: break; - case Event::OnMouseUp://鼠标抬起 - { - TableView* tableView = (TableView*)FindControl("tableViewAdmin"); //获取表格控件 - int pRow = tableView->GetHoverRow(); //当前行号 - int pCol = tableView->GetHoverCol(); //当前列号 - std::cout << "当前行列号: (" << pRow << ", " << pCol << ")\n"; - UIString celContent = tableView->GetData(pRow, pCol); - std::cout << "单元格内容: " << celContent.ansi() << std::endl; - } - - break; - default: - std::cout << "表格事件:" << (long long)eventType << std::endl; - break; - } - } + //if (btnName == "tableViewAdmin") { + // switch (eventType) + // { + // case 8: break; + // case Event::OnMouseUp://鼠标抬起 + // { + // TableView* tableView = (TableView*)FindControl("tableViewAdmin"); //获取表格控件 + // } + // break; + // default: + // std::cout << "表格事件:" << (long long)eventType << std::endl; + // break; + // } + //} switch (eventType) { @@ -138,7 +132,24 @@ mainForm::mainForm() :LayeredWindow(1000, 750) tableView->SetColumnComboItems(2, { L"默认", L"禁止" , L"验机" }); //设置列宽 //std::vector withs = {80, 100}; + + + + // 鼠标右键单击的回调 + tableView->RightClick = [tableView](int row, int col) { + int pRow = tableView->GetHoverRow(); //当前行号 + int pCol = tableView->GetHoverCol(); //当前列号 + UIString celContent = tableView->GetData(pRow, pCol); + //std::cout << "单元格内容: " << celContent.ansi() << std::endl; + std::cout << "当前列宽: " << tableView->GetColumnWidth(pCol) << std::endl; + }; + // 单元格编辑完成(编辑结束时触发,提供旧值与新值) + tableView->CellEditFinished = [](int row, int col, const UIString& oldValue, const UIString& newValue) { + std::cout << "单元格内容: " << newValue.ansi() << ", " << oldValue.ansi() << std::endl; + }; } + + } mainForm::~mainForm() diff --git a/demo/Adminstor/ThirdParty/EzUI/include/EzUI/TableView.h b/demo/Adminstor/ThirdParty/EzUI/include/EzUI/TableView.h index 71437f7..bb1b8d4 100644 --- a/demo/Adminstor/ThirdParty/EzUI/include/EzUI/TableView.h +++ b/demo/Adminstor/ThirdParty/EzUI/include/EzUI/TableView.h @@ -253,6 +253,10 @@ namespace ezui { // 参数: row, col, oldValue, newValue std::function CellEditFinished = nullptr; + // 鼠标右键单击回调 + // 参数: row, col (row=-1 表示点击在表头,col=-1 表示点击在第一列) + std::function RightClick = nullptr; + public: TableView(Object* parentObject = nullptr); virtual ~TableView(); diff --git a/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_Win32.lib b/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_Win32.lib index d6abbf8..69b09f5 100644 Binary files a/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_Win32.lib and b/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_Win32.lib differ diff --git a/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_Win32.pdb b/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_Win32.pdb index af364f7..71c1d2c 100644 Binary files a/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_Win32.pdb and b/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_Win32.pdb differ diff --git a/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_x64.lib b/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_x64.lib index fc7dcdc..b5384e0 100644 Binary files a/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_x64.lib and b/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_x64.lib differ diff --git a/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_x64.pdb b/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_x64.pdb index 82c502f..2545cbf 100644 Binary files a/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_x64.pdb and b/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_x64.pdb differ diff --git a/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Release_Win32.lib b/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Release_Win32.lib index 7a568fb..ca2568b 100644 Binary files a/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Release_Win32.lib and b/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Release_Win32.lib differ diff --git a/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Release_x64.lib b/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Release_x64.lib index 12ff85a..ad0c05d 100644 Binary files a/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Release_x64.lib and b/demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Release_x64.lib differ diff --git a/include/EzUI/TableView.h b/include/EzUI/TableView.h index 71437f7..bb1b8d4 100644 --- a/include/EzUI/TableView.h +++ b/include/EzUI/TableView.h @@ -253,6 +253,10 @@ namespace ezui { // 参数: row, col, oldValue, newValue std::function CellEditFinished = nullptr; + // 鼠标右键单击回调 + // 参数: row, col (row=-1 表示点击在表头,col=-1 表示点击在第一列) + std::function RightClick = nullptr; + public: TableView(Object* parentObject = nullptr); virtual ~TableView(); diff --git a/lib/EzUI_Debug_Win32.lib b/lib/EzUI_Debug_Win32.lib index d6abbf8..69b09f5 100644 Binary files a/lib/EzUI_Debug_Win32.lib and b/lib/EzUI_Debug_Win32.lib differ diff --git a/lib/EzUI_Debug_Win32.pdb b/lib/EzUI_Debug_Win32.pdb index af364f7..71c1d2c 100644 Binary files a/lib/EzUI_Debug_Win32.pdb and b/lib/EzUI_Debug_Win32.pdb differ diff --git a/lib/EzUI_Debug_x64.lib b/lib/EzUI_Debug_x64.lib index fc7dcdc..b5384e0 100644 Binary files a/lib/EzUI_Debug_x64.lib and b/lib/EzUI_Debug_x64.lib differ diff --git a/lib/EzUI_Debug_x64.pdb b/lib/EzUI_Debug_x64.pdb index 82c502f..2545cbf 100644 Binary files a/lib/EzUI_Debug_x64.pdb and b/lib/EzUI_Debug_x64.pdb differ diff --git a/lib/EzUI_Release_Win32.lib b/lib/EzUI_Release_Win32.lib index 7a568fb..ca2568b 100644 Binary files a/lib/EzUI_Release_Win32.lib and b/lib/EzUI_Release_Win32.lib differ diff --git a/lib/EzUI_Release_x64.lib b/lib/EzUI_Release_x64.lib index 12ff85a..ad0c05d 100644 Binary files a/lib/EzUI_Release_x64.lib and b/lib/EzUI_Release_x64.lib differ diff --git a/sources/TableView.cpp b/sources/TableView.cpp index 79382ac..72637b4 100644 --- a/sources/TableView.cpp +++ b/sources/TableView.cpp @@ -906,6 +906,17 @@ namespace ezui { void TableView::OnMouseDown(const MouseEventArgs& args) { __super::OnMouseDown(args); + // 右键单击 + if (args.Button == MouseButton::Right) { + int row, col; + if (HitTestCell(args.Location, &row, &col)) { + if (RightClick) { + RightClick(row, col); + } + } + return; + } + if (args.Button != MouseButton::Left) { return; }