imgui-node-editor
imgui-node-editor copied to clipboard
use `space` key to replace right mouse to open menu for create nodes.
Many thanks to themd for your great work, I'm using imgui-node-editor to create some custom nodes and it works great.
But I found that the right mouse button is used to move the canvas and trigger the menu at the same time, which causes some right-click events to not open the menu.
So I want to use the space key instead of the right mouse button to open the menu. The right mouse button only needs to do the job of moving the canvas.
How can I change the key configuration to make the space bar work for me? Thank you very much!
OK, I solved this problem by changing the keyboard mapping. Thank you very much!
Config()
: SettingsFile("NodeEditor.json")
, BeginSaveSession(nullptr)
, EndSaveSession(nullptr)
, SaveSettings(nullptr)
, LoadSettings(nullptr)
, SaveNodeSettings(nullptr)
, LoadNodeSettings(nullptr)
, UserPointer(nullptr)
, CustomZoomLevels()
, CanvasSizeMode(CanvasSizeModeAlias::FitVerticalView)
, DragButtonIndex(0)
, SelectButtonIndex(0)
, NavigateButtonIndex(1)
, ContextMenuButtonIndex(ImGuiKey_Space)
, EnableSmoothZoom(false)
...
const auto isPressed = ImGui::IsKeyPressed((ImGuiKey)Editor->GetConfig().ContextMenuButtonIndex);
const auto isReleased = ImGui::IsKeyReleased((ImGuiKey)Editor->GetConfig().ContextMenuButtonIndex);
if (isPressed || isReleased)
...