diff --git a/src/ui/simple/CSimpleFrame.cpp b/src/ui/simple/CSimpleFrame.cpp index 4832f4f..1257cd1 100644 --- a/src/ui/simple/CSimpleFrame.cpp +++ b/src/ui/simple/CSimpleFrame.cpp @@ -100,6 +100,18 @@ void CSimpleFrame::DisableDrawLayer(uint32_t drawlayer) { this->NotifyDrawLayerChanged(drawlayer); } +void CSimpleFrame::DisableEvent(CSimpleEventType eventType) { + if (!(this->m_eventmask & (1 << eventType))) { + return; + } + + if (this->m_visible) { + this->m_top->UnregisterForEvent(this, eventType, 0); + } + + this->m_eventmask &= ~(1 << eventType); +} + void CSimpleFrame::EnableDrawLayer(uint32_t drawlayer) { this->m_drawenabled[drawlayer] = 1; this->NotifyDrawLayerChanged(drawlayer); diff --git a/src/ui/simple/CSimpleFrame.hpp b/src/ui/simple/CSimpleFrame.hpp index 2807794..2f08b23 100644 --- a/src/ui/simple/CSimpleFrame.hpp +++ b/src/ui/simple/CSimpleFrame.hpp @@ -123,6 +123,7 @@ class CSimpleFrame : public CScriptRegion { CSimpleFrame(CSimpleFrame* parent); void AddFrameRegion(CSimpleRegion* region, uint32_t drawlayer); void DisableDrawLayer(uint32_t drawlayer); + void DisableEvent(CSimpleEventType eventType); void EnableDrawLayer(uint32_t drawlayer); void EnableEvent(CSimpleEventType eventType, int32_t priority); int32_t GetHitRect(CRect& rect); diff --git a/src/ui/simple/CSimpleFrameScript.cpp b/src/ui/simple/CSimpleFrameScript.cpp index 2b63fb0..ca9d743 100644 --- a/src/ui/simple/CSimpleFrameScript.cpp +++ b/src/ui/simple/CSimpleFrameScript.cpp @@ -4,6 +4,7 @@ #include "ui/FrameScript.hpp" #include "ui/simple/CSimpleFrame.hpp" #include "util/Lua.hpp" +#include "util/StringTo.hpp" #include "util/Unimplemented.hpp" #include #include @@ -459,7 +460,22 @@ int32_t CSimpleFrame_IsKeyboardEnabled(lua_State* L) { } int32_t CSimpleFrame_EnableMouse(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + auto type = CSimpleFrame::GetObjectType(); + auto frame = static_cast(FrameScript_GetObjectThis(L, type)); + + if (!frame->ProtectedFunctionsAllowed()) { + // TODO disallowed logic + + return 0; + } + + if (StringToBOOL(L, 2, 1)) { + frame->EnableEvent(SIMPLE_EVENT_MOUSE, -1); + } else { + frame->DisableEvent(SIMPLE_EVENT_MOUSE); + } + + return 0; } int32_t CSimpleFrame_IsMouseEnabled(lua_State* L) {