Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use space key to replace right mouse to open menu for create nodes. #312

Open
ElonKou opened this issue Nov 21, 2024 · 1 comment
Open

Comments

@ElonKou
Copy link

ElonKou commented Nov 21, 2024

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!

@ElonKou
Copy link
Author

ElonKou commented Nov 21, 2024

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)
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant