Merge pull request #83 from BalazsJako/dev
Merging to master
diff --git a/TextEditor.cpp b/TextEditor.cpp
index d493d01..c48e050 100644
--- a/TextEditor.cpp
+++ b/TextEditor.cpp
@@ -43,6 +43,9 @@
, mSelectionMode(SelectionMode::Normal)
, mCheckComments(true)
, mLastClick(-1.0f)
+ , mHandleKeyboardInputs(true)
+ , mHandleMouseInputs(true)
+ , mIgnoreImGuiChild(false)
{
SetPalette(GetDarkPalette());
SetLanguageDefinition(LanguageDefinition::HLSL());
@@ -461,7 +464,7 @@
if (ImGui::IsWindowFocused())
{
- if (ImGui::IsWindowHovered())
+ if (ImGui::IsWindowHovered() && !ImGui::IsAnyItemHovered() && !ImGui::IsAnyItemFocused())
ImGui::SetMouseCursor(ImGuiMouseCursor_TextInput);
//ImGui::CaptureKeyboardFromApp(true);
@@ -836,16 +839,22 @@
ImGui::PushStyleColor(ImGuiCol_ChildWindowBg, ImGui::ColorConvertU32ToFloat4(mPalette[(int)PaletteIndex::Background]));
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f));
- ImGui::BeginChild(aTitle, aSize, aBorder, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NoMove);
- ImGui::PushAllowKeyboardFocus(true);
+ if( !mIgnoreImGuiChild)
+ ImGui::BeginChild(aTitle, aSize, aBorder, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NoMove);
+
+ if (mHandleKeyboardInputs) {
+ HandleKeyboardInputs();
+ ImGui::PushAllowKeyboardFocus(true);
+ }
- HandleKeyboardInputs();
- HandleMouseInputs();
+ if( mHandleMouseInputs) HandleMouseInputs();
+
ColorizeInternal();
Render();
- ImGui::PopAllowKeyboardFocus();
- ImGui::EndChild();
+ if (mHandleKeyboardInputs) ImGui::PopAllowKeyboardFocus();
+
+ if( !mIgnoreImGuiChild) ImGui::EndChild();
ImGui::PopStyleVar();
ImGui::PopStyleColor();
diff --git a/TextEditor.h b/TextEditor.h
index 66df7eb..cfc68d5 100644
--- a/TextEditor.h
+++ b/TextEditor.h
@@ -206,6 +206,10 @@
Coordinates GetCursorPosition() const { return GetActualCursorCoordinates(); }
void SetCursorPosition(const Coordinates& aPosition);
+ void SetHandleMouseInputs (bool aValue){ mHandleMouseInputs = aValue;}
+ void SetHandleKeyboardInputs (bool aValue){ mHandleKeyboardInputs = aValue;}
+ void SetImGuiChildIgnored (bool aValue){ mIgnoreImGuiChild = aValue;}
+
void InsertText(const std::string& aValue);
void InsertText(const char* aValue);
@@ -335,6 +339,9 @@
bool mCursorPositionChanged;
int mColorRangeMin, mColorRangeMax;
SelectionMode mSelectionMode;
+ bool mHandleKeyboardInputs;
+ bool mHandleMouseInputs;
+ bool mIgnoreImGuiChild;
Palette mPaletteBase;
Palette mPalette;