added method for requesting imgui focus

This commit is contained in:
Lendemor 2018-04-11 17:28:57 +02:00
parent 01ef5c4e1c
commit bd1031139f
2 changed files with 15 additions and 3 deletions

View File

@ -13,6 +13,7 @@
Input::Input(sf::Window *w) : Input::Input(sf::Window *w) :
m_window(w), m_window(w),
m_closeRequested(false), m_closeRequested(false),
m_imgui_requested_focus(false),
m_mouseGrabbed(false), m_mouseGrabbed(false),
m_mouseWasGrabbed(false) m_mouseWasGrabbed(false)
{ {
@ -71,9 +72,9 @@ void Input::updateEvents(){
m_actions.clear(); m_actions.clear();
Action action; Action action;
bool focus_on_imgui = false;
if(m_imgui_requested_focus)
bool focus_on_imgui = ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow); focus_on_imgui = ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow);
if(focus_on_imgui) if(focus_on_imgui)
std::cout << "focused" << std::endl; std::cout << "focused" << std::endl;
@ -258,6 +259,14 @@ bool Input::isResized() const
return m_hasBeenResized; return m_hasBeenResized;
} }
void Input::ImguiRequestFocus(){
m_imgui_requested_focus = true;
}
void Input::ImguiReleaseFocus(){
m_imgui_requested_focus = false;
}
/* keyboard-related functions */ /* keyboard-related functions */
bool Input::isKeyPressed(int key) const bool Input::isKeyPressed(int key) const

View File

@ -18,6 +18,7 @@ private:
sf::Window* m_window; sf::Window* m_window;
bool m_closeRequested; bool m_closeRequested;
bool m_hasBeenResized; bool m_hasBeenResized;
bool m_imgui_requested_focus;
/* general action-mapping variables */ /* general action-mapping variables */
IKeysMap m_keysmap; IKeysMap m_keysmap;
@ -69,6 +70,8 @@ public:
/* window-related function */ /* window-related function */
bool isCloseRequested() const; bool isCloseRequested() const;
bool isResized() const; bool isResized() const;
void ImguiRequestFocus();
void ImguiReleaseFocus();
/* keyboard-related functions */ /* keyboard-related functions */
bool isKeyPressed(int key) const; bool isKeyPressed(int key) const;