Added key response, now you can use Ctrl+A to select all nodes. Ctrl+X currently only deletes the selected part, and may support clipboard in the future. && Added a delete selected content function in the right-click menu.

This commit is contained in:
LuChiChick 2026-04-02 19:04:07 +08:00
parent 7aa8c6750d
commit a23f562906

View File

@ -10,6 +10,11 @@ extern "C"
// 绘制节点编辑器
void Workflow_Editor::Show(void)
{
// 选区信息
bool bounding_box_delete_flag = false;
int bounding_box_link_nums = ImNodes::NumSelectedLinks();
int bounding_box_node_nums = ImNodes::NumSelectedNodes();
// 浅色主题节点编辑器窗体
ImNodes::StyleColorsLight();
ImNodes::BeginNodeEditor();
@ -56,6 +61,10 @@ void Workflow_Editor::Show(void)
ImGui::EndMenu();
}
// 删除框选内容
if (ImGui::MenuItem(u8"删除所选内容", nullptr, nullptr, (bounding_box_link_nums > 0) || (bounding_box_node_nums > 0)))
bounding_box_delete_flag = true;
ImGui::EndPopup();
}
ImGui::PopStyleVar();
@ -79,8 +88,30 @@ void Workflow_Editor::Show(void)
// 处理键盘事件
{
// Delete 按键释放
if (ImGui::IsKeyReleased(ImGuiKey_Delete))
// Ctrl + A 全选
if (ImGui::IsKeyChordPressed(ImGuiMod_Ctrl | ImGuiKey_A) == true)
{
for (auto Link : this->Edge_Pool)
if (ImNodes::IsLinkSelected(Link.id) == false)
ImNodes::SelectLink(Link.id);
for (auto pNode : this->Node_Pool)
if (ImNodes::IsNodeSelected(pNode->Get_ID()) == false)
ImNodes::SelectNode(pNode->Get_ID());
}
// Ctrl + X 剪切
if (ImGui::IsKeyChordPressed(ImGuiMod_Ctrl | ImGuiKey_X) == true)
{
bounding_box_delete_flag = true;
/**
* @todo
*
*/
}
// Delete 按键释放 或有删除请求
if (ImGui::IsKeyReleased(ImGuiKey_Delete) || bounding_box_delete_flag)
{
// 释放所有选中的边
{