Skip to content

Commit 345becf

Browse files
committed
Editor: Make selection rect start at click point
1 parent 09ce80d commit 345becf

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

docs/CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,4 @@ v0.9.1 (WIP):
179179

180180
BUGFIX: Editor: Improve link dragging with fast movement (#156)
181181

182+
BUGFIX: Editor: Make selection rect start at click point

imgui_node_editor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3917,7 +3917,7 @@ ed::EditorAction::AcceptResult ed::SelectAction::Accept(const Control& control)
39173917
if (Editor->CanAcceptUserInput() && control.BackgroundHot && ImGui::IsMouseDragging(Editor->GetConfig().SelectButtonIndex, 1))
39183918
{
39193919
m_IsActive = true;
3920-
m_StartPoint = ImGui::GetMousePos();
3920+
m_StartPoint = ImGui_GetMouseClickPos(Editor->GetConfig().SelectButtonIndex);
39213921
m_EndPoint = m_StartPoint;
39223922

39233923
// Links and nodes cannot be selected together

imgui_node_editor_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ void Log(const char* fmt, ...);
5656
//inline ImRect ToRect(const ax::rectf& rect);
5757
//inline ImRect ToRect(const ax::rect& rect);
5858
inline ImRect ImGui_GetItemRect();
59+
inline ImVec2 ImGui_GetMouseClickPos(ImGuiMouseButton buttonIndex);
5960

6061

6162
//------------------------------------------------------------------------------

imgui_node_editor_internal.inl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ inline ImRect ImGui_GetItemRect()
4646
return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
4747
}
4848

49+
inline ImVec2 ImGui_GetMouseClickPos(ImGuiMouseButton buttonIndex)
50+
{
51+
if (ImGui::IsMouseDown(buttonIndex))
52+
return ImGui::GetIO().MouseClickedPos[buttonIndex];
53+
else
54+
return ImGui::GetMousePos();
55+
}
56+
4957

5058
//------------------------------------------------------------------------------
5159
} // namespace Detail

0 commit comments

Comments
 (0)