two new lua mouse up events (4 & 5) for some corner cases
Also fixes mouse held event being stuck in one of those cases
This commit is contained in:
parent
cd97d6364b
commit
16781bcb8e
@ -594,9 +594,11 @@ bool GameController::MouseDown(int x, int y, unsigned button)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool GameController::MouseUp(int x, int y, unsigned button)
|
||||
bool GameController::MouseUp(int x, int y, unsigned button, char type)
|
||||
{
|
||||
bool ret = commandInterface->OnMouseUp(x, y, button);
|
||||
bool ret = commandInterface->OnMouseUp(x, y, button, type);
|
||||
if (type)
|
||||
return ret;
|
||||
if (ret && foundSign && y<YRES && x<XRES && !gameView->GetPlacingSave())
|
||||
{
|
||||
ui::Point point = gameModel->AdjustZoomCoords(ui::Point(x, y));
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
|
||||
bool MouseMove(int x, int y, int dx, int dy);
|
||||
bool MouseDown(int x, int y, unsigned button);
|
||||
bool MouseUp(int x, int y, unsigned button);
|
||||
bool MouseUp(int x, int y, unsigned button, char type);
|
||||
bool MouseWheel(int x, int y, int d);
|
||||
bool KeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
||||
bool KeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
||||
|
@ -480,7 +480,7 @@ public:
|
||||
}
|
||||
void MouseEnterCallback(ui::Button * sender)
|
||||
{
|
||||
if(!needsClick && !ui::Engine::Ref().GetMouseButton())
|
||||
if(!needsClick && !v->GetMouseDown())
|
||||
v->c->SetActiveMenu(menuID);
|
||||
}
|
||||
void ActionCallback(ui::Button * sender)
|
||||
@ -1075,7 +1075,10 @@ void GameView::OnMouseMove(int x, int y, int dx, int dy)
|
||||
}
|
||||
}
|
||||
else if (drawMode == DrawPoints || drawMode == DrawFill)
|
||||
{
|
||||
isMouseDown = false;
|
||||
c->MouseUp(x, y, 0, 2);
|
||||
}
|
||||
}
|
||||
mouseInZoom = newMouseInZoom;
|
||||
}
|
||||
@ -1614,6 +1617,7 @@ void GameView::OnBlur()
|
||||
disableShiftBehaviour();
|
||||
isMouseDown = false;
|
||||
drawMode = DrawPoints;
|
||||
c->MouseUp(0, 0, 0, 1); // tell lua that mouse is up (even if it really isn't)
|
||||
}
|
||||
|
||||
void GameView::OnTick(float dt)
|
||||
@ -1773,7 +1777,7 @@ void GameView::DoMouseDown(int x, int y, unsigned button)
|
||||
|
||||
void GameView::DoMouseUp(int x, int y, unsigned button)
|
||||
{
|
||||
if(c->MouseUp(x, y, button))
|
||||
if(c->MouseUp(x, y, button, 0))
|
||||
Window::DoMouseUp(x, y, button);
|
||||
}
|
||||
|
||||
|
@ -147,6 +147,7 @@ public:
|
||||
void BeginStampSelection();
|
||||
|
||||
//all of these are only here for one debug lines
|
||||
bool GetMouseDown() { return isMouseDown; }
|
||||
bool GetDrawingLine() { return drawMode == DrawLine && isMouseDown; }
|
||||
bool GetDrawSnap() { return drawSnap; }
|
||||
ui::Point GetLineStartCoords() { return drawPoint1; }
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
virtual bool OnActiveToolChanged(int toolSelection, Tool * tool) {return true;}
|
||||
virtual bool OnMouseMove(int x, int y, int dx, int dy) {return true;}
|
||||
virtual bool OnMouseDown(int x, int y, unsigned button) {return true;}
|
||||
virtual bool OnMouseUp(int x, int y, unsigned button) {return true;}
|
||||
virtual bool OnMouseUp(int x, int y, unsigned button, char type) {return true;}
|
||||
virtual bool OnMouseWheel(int x, int y, int d) {return true;}
|
||||
virtual bool OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) {return true;}
|
||||
virtual bool OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt) {return true;}
|
||||
|
@ -3220,13 +3220,29 @@ bool LuaScriptInterface::OnMouseDown(int x, int y, unsigned button)
|
||||
return luacon_mouseevent(x, y, button, LUACON_MDOWN, 0);
|
||||
}
|
||||
|
||||
bool LuaScriptInterface::OnMouseUp(int x, int y, unsigned button)
|
||||
bool LuaScriptInterface::OnMouseUp(int x, int y, unsigned button, char type)
|
||||
{
|
||||
luacon_mousebutton = 0;
|
||||
if (button == 3)
|
||||
button = 4;
|
||||
|
||||
// mouse was never down, probably due to fake mouse event
|
||||
if (!luacon_mousedown)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// fake mouseup event, triggered when mouse drawing is canceled due to moving in / out of the zoom window
|
||||
if (type == 2)
|
||||
return luacon_mouseevent(x, y, button, LUACON_MUPZOOM, 0);
|
||||
|
||||
luacon_mousedown = false;
|
||||
luacon_mousebutton = 0;
|
||||
return luacon_mouseevent(x, y, button, LUACON_MUP, 0);
|
||||
|
||||
// fake mouseup event, triggered when user enters another interface while the mouse is down
|
||||
if (type == 1)
|
||||
return luacon_mouseevent(x, y, button, LUACON_MUPALT, 0);
|
||||
else
|
||||
return luacon_mouseevent(x, y, button, LUACON_MUP, 0);
|
||||
}
|
||||
|
||||
bool LuaScriptInterface::OnMouseWheel(int x, int y, int d)
|
||||
|
@ -18,6 +18,8 @@ class Tool;
|
||||
#define LUACON_MDOWN 1
|
||||
#define LUACON_MUP 2
|
||||
#define LUACON_MPRESS 3
|
||||
#define LUACON_MUPALT 4
|
||||
#define LUACON_MUPZOOM 5
|
||||
#define LUACON_KDOWN 1
|
||||
#define LUACON_KUP 2
|
||||
|
||||
@ -171,7 +173,7 @@ public:
|
||||
virtual bool OnActiveToolChanged(int toolSelection, Tool * tool);
|
||||
virtual bool OnMouseMove(int x, int y, int dx, int dy);
|
||||
virtual bool OnMouseDown(int x, int y, unsigned button);
|
||||
virtual bool OnMouseUp(int x, int y, unsigned button);
|
||||
virtual bool OnMouseUp(int x, int y, unsigned button, char type);
|
||||
virtual bool OnMouseWheel(int x, int y, int d);
|
||||
virtual bool OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
||||
virtual bool OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
||||
|
Reference in New Issue
Block a user