diff --git a/Kiwano/2d/Layer.cpp b/Kiwano/2d/Layer.cpp index cd37c9e8..e9d2483a 100644 --- a/Kiwano/2d/Layer.cpp +++ b/Kiwano/2d/Layer.cpp @@ -25,17 +25,20 @@ namespace kiwano { Layer::Layer() + : swallow_(false) { SetSize(Renderer::Instance().GetOutputSize()); - AddListener(Event::MouseBtnDown, MakeClosure(this, &Layer::HandleMessages)); - AddListener(Event::MouseBtnUp, MakeClosure(this, &Layer::HandleMessages)); - AddListener(Event::MouseMove, MakeClosure(this, &Layer::HandleMessages)); - AddListener(Event::MouseWheel, MakeClosure(this, &Layer::HandleMessages)); + auto handler = MakeClosure(this, &Layer::HandleMessages); - AddListener(Event::KeyDown, MakeClosure(this, &Layer::HandleMessages)); - AddListener(Event::KeyUp, MakeClosure(this, &Layer::HandleMessages)); - AddListener(Event::Char, MakeClosure(this, &Layer::HandleMessages)); + AddListener(Event::MouseBtnDown, handler); + AddListener(Event::MouseBtnUp, handler); + AddListener(Event::MouseMove, handler); + AddListener(Event::MouseWheel, handler); + + AddListener(Event::KeyDown, handler); + AddListener(Event::KeyUp, handler); + AddListener(Event::Char, handler); } Layer::~Layer() @@ -47,11 +50,14 @@ namespace kiwano if (!IsVisible()) return; - NodePtr prev; - for (auto child = children_.Last(); child; child = prev) + if (!swallow_) { - prev = child->PrevItem(); - child->Dispatch(evt); + NodePtr prev; + for (auto child = children_.Last(); child; child = prev) + { + prev = child->PrevItem(); + child->Dispatch(evt); + } } EventDispatcher::Dispatch(evt); diff --git a/Kiwano/2d/Layer.h b/Kiwano/2d/Layer.h index 89388a55..6d70be9a 100644 --- a/Kiwano/2d/Layer.h +++ b/Kiwano/2d/Layer.h @@ -40,10 +40,16 @@ namespace kiwano virtual void OnKeyUp(int key) {} virtual void OnChar(char c) {} + // ÍÌûÏûÏ¢ + inline void SetSwallowEvents(bool enabled) { swallow_ = enabled; } + public: void Dispatch(Event& evt) override; protected: void HandleMessages(Event const& evt); + + protected: + bool swallow_; }; } diff --git a/Kiwano/imgui/ImGuiLayer.cpp b/Kiwano/imgui/ImGuiLayer.cpp index e206140c..b0d4c7c9 100644 --- a/Kiwano/imgui/ImGuiLayer.cpp +++ b/Kiwano/imgui/ImGuiLayer.cpp @@ -35,6 +35,7 @@ namespace kiwano ImGuiLayer::ImGuiLayer() { target_window_ = Renderer::Instance().GetTargetWindow(); + SetSwallowEvents(true); } ImGuiLayer::~ImGuiLayer() diff --git a/Kiwano/network/HttpClient.cpp b/Kiwano/network/HttpClient.cpp index 001569ce..7fa21bc3 100644 --- a/Kiwano/network/HttpClient.cpp +++ b/Kiwano/network/HttpClient.cpp @@ -41,7 +41,7 @@ namespace // write data maybe called more than once in a single request recv_buffer->append((char*)buffer, total); - return total; + return total; } std::string convert_to_utf8(String const& str)