Skip to content

Commit

Permalink
Fix keyboard input focus in Graph Editor (#1596)
Browse files Browse the repository at this point in the history
Changed IsWindowFocused flags for inputs mentioned in #1424 to prevent all panels from responding.
  • Loading branch information
HudsonHN authored Jun 30, 2024
1 parent b1a3e42 commit ad0615b
Showing 1 changed file with 40 additions and 37 deletions.
77 changes: 40 additions & 37 deletions source/MaterialXGraphEditor/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3622,7 +3622,7 @@ void Graph::showHelp() const

void Graph::addNodePopup(bool cursor)
{
bool open_AddPopup = ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) && ImGui::IsKeyReleased(ImGuiKey_Tab);
bool open_AddPopup = ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow) && ImGui::IsKeyReleased(ImGuiKey_Tab);
static char input[32]{ "" };
if (open_AddPopup)
{
Expand Down Expand Up @@ -4068,55 +4068,58 @@ void Graph::drawGraph(ImVec2 mousePos)
_initial = false;
_autoLayout = false;

// Start the session with content centered
if (ImGui::GetFrameCount() == 2)
{
ed::NavigateToContent(0.0f);
}

// Delete selected nodes and their links if delete key is pressed
// or if the shortcut for cut is used
if (ImGui::IsKeyReleased(ImGuiKey_Delete) || _isCut)
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow))
{
if (selectedNodes.size() > 0)
if (ImGui::IsKeyReleased(ImGuiKey_Delete) || _isCut)
{
_frameCount = ImGui::GetFrameCount();
_renderer->setMaterialCompilation(true);
for (ed::NodeId id : selectedNodes)
if (selectedNodes.size() > 0)
{

if (int(id.Get()) > 0)
_frameCount = ImGui::GetFrameCount();
_renderer->setMaterialCompilation(true);
for (ed::NodeId id : selectedNodes)
{
int pos = findNode(int(id.Get()));
if (pos >= 0 && !readOnly())
{
deleteNode(_graphNodes[pos]);
_delete = true;
ed::DeselectNode(id);
ed::DeleteNode(id);
_currUiNode = nullptr;
}
else if (readOnly())

if (int(id.Get()) > 0)
{
_popup = true;
int pos = findNode(int(id.Get()));
if (pos >= 0 && !readOnly())
{
deleteNode(_graphNodes[pos]);
_delete = true;
ed::DeselectNode(id);
ed::DeleteNode(id);
_currUiNode = nullptr;
}
else if (readOnly())
{
_popup = true;
}
}
}
linkGraph();
}
linkGraph();
_isCut = false;
}
_isCut = false;
}

// Start the session with content centered
if (ImGui::GetFrameCount() == 2)
{
ed::NavigateToContent(0.0f);
}

// Hotkey to frame selected node(s)
if (ImGui::IsKeyReleased(ImGuiKey_F) && !_fileDialogSave.isOpened())
{
ed::NavigateToSelection();
}
// Hotkey to frame selected node(s)
if (ImGui::IsKeyReleased(ImGuiKey_F) && !_fileDialogSave.isOpened())
{
ed::NavigateToSelection();
}

// Go back up from inside a subgraph
if (ImGui::IsKeyReleased(ImGuiKey_U) && (!ImGui::IsPopupOpen("add node")) && (!ImGui::IsPopupOpen("search")) && !_fileDialogSave.isOpened())
{
upNodeGraph();
// Go back up from inside a subgraph
if (ImGui::IsKeyReleased(ImGuiKey_U) && (!ImGui::IsPopupOpen("add node")) && (!ImGui::IsPopupOpen("search")) && !_fileDialogSave.isOpened())
{
upNodeGraph();
}
}

// Add new link
Expand Down

0 comments on commit ad0615b

Please sign in to comment.