Skip to content

Commit 3b3775a

Browse files
committed
Add blur lua event, called when opening another interface window
1 parent 9e94abb commit 3b3775a

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

src/gui/game/GameController.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,14 @@ void GameController::Tick()
863863
commandInterface->OnTick();
864864
}
865865

866+
void GameController::Blur()
867+
{
868+
// Tell lua that mouse is up (even if it really isn't)
869+
MouseUp(0, 0, 0, 1);
870+
BlurEvent ev;
871+
commandInterface->HandleEvent(LuaEvents::blur, &ev);
872+
}
873+
866874
void GameController::Exit()
867875
{
868876
CloseEvent ev;

src/gui/game/GameController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class GameController: public ClientListener
6868
bool KeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
6969
bool KeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
7070
void Tick();
71+
void Blur();
7172
void Exit();
7273

7374
void Install();

src/gui/game/GameView.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,9 +1700,7 @@ void GameView::OnBlur()
17001700
disableShiftBehaviour();
17011701
isMouseDown = false;
17021702
drawMode = DrawPoints;
1703-
c->MouseUp(0, 0, 0, 1); // tell lua that mouse is up (even if it really isn't)
1704-
if (GetModifiers())
1705-
c->KeyRelease(0, 0, false, false, false, false);
1703+
c->Blur();
17061704
}
17071705

17081706
void GameView::OnTick(float dt)

src/lua/LuaEvents.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ class TickEvent: public Event
9898
int PushToStack(lua_State *l) override { return 0; }
9999
};
100100

101+
class BlurEvent: public Event
102+
{
103+
public:
104+
int PushToStack(lua_State *l) override { return 0; }
105+
};
106+
101107
class CloseEvent: public Event
102108
{
103109
public:
@@ -116,6 +122,7 @@ class LuaEvents
116122
mousemove,
117123
mousewheel,
118124
tick,
125+
blur,
119126
close
120127
};
121128

src/lua/LuaScriptInterface.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3314,6 +3314,7 @@ void LuaScriptInterface::initEventAPI()
33143314
lua_pushinteger(l, LuaEvents::mousemove); lua_setfield(l, -2, "mousemove");
33153315
lua_pushinteger(l, LuaEvents::mousewheel); lua_setfield(l, -2, "mousewheel");
33163316
lua_pushinteger(l, LuaEvents::tick); lua_setfield(l, -2, "tick");
3317+
lua_pushinteger(l, LuaEvents::blur); lua_setfield(l, -2, "blur");
33173318
lua_pushinteger(l, LuaEvents::close); lua_setfield(l, -2, "close");
33183319
}
33193320

0 commit comments

Comments
 (0)