mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 13:23:56 -07:00
Add GUI events for middle mouse click
Summary: Add gui events for middle mouse click Differential Revision: https://code.wildfiregames.com/D1752 This was SVN commit r23505.
This commit is contained in:
parent
f12feba62d
commit
0916ffbbb1
3 changed files with 26 additions and 0 deletions
|
|
@ -53,12 +53,15 @@ const CStr CGUI::EventNamePress = "Press";
|
|||
const CStr CGUI::EventNameRelease = "Release";
|
||||
const CStr CGUI::EventNameMouseRightPress = "MouseRightPress";
|
||||
const CStr CGUI::EventNameMouseLeftPress = "MouseLeftPress";
|
||||
const CStr CGUI::EventNameMouseMiddlePress = "MouseMiddlePress";
|
||||
const CStr CGUI::EventNameMouseWheelDown = "MouseWheelDown";
|
||||
const CStr CGUI::EventNameMouseWheelUp = "MouseWheelUp";
|
||||
const CStr CGUI::EventNameMouseLeftDoubleClick = "MouseLeftDoubleClick";
|
||||
const CStr CGUI::EventNameMouseLeftRelease = "MouseLeftRelease";
|
||||
const CStr CGUI::EventNameMouseRightDoubleClick = "MouseRightDoubleClick";
|
||||
const CStr CGUI::EventNameMouseRightRelease = "MouseRightRelease";
|
||||
const CStr CGUI::EventNameMouseMiddleDoubleClick = "MouseMiddleDoubleClick";
|
||||
const CStr CGUI::EventNameMouseMiddleRelease = "MouseMiddleRelease";
|
||||
|
||||
CGUI::CGUI(const shared_ptr<ScriptRuntime>& runtime)
|
||||
: m_BaseObject(*this),
|
||||
|
|
@ -179,6 +182,11 @@ InReaction CGUI::HandleEvent(const SDL_Event_* ev)
|
|||
ret = pNearest->SendMouseEvent(GUIM_MOUSE_PRESS_RIGHT, EventNameMouseRightPress);
|
||||
break;
|
||||
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
if (pNearest)
|
||||
ret = pNearest->SendEvent(GUIM_MOUSE_PRESS_MIDDLE, EventNameMouseMiddlePress);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -216,6 +224,18 @@ InReaction CGUI::HandleEvent(const SDL_Event_* ev)
|
|||
ret = pNearest->SendMouseEvent(GUIM_MOUSE_RELEASE_RIGHT, EventNameMouseRightRelease);
|
||||
}
|
||||
break;
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
if (pNearest)
|
||||
{
|
||||
double timeElapsed = timer_Time() - pNearest->m_LastClickTime[SDL_BUTTON_MIDDLE];
|
||||
pNearest->m_LastClickTime[SDL_BUTTON_MIDDLE] = timer_Time();
|
||||
|
||||
if (timeElapsed < SELECT_DBLCLICK_RATE)
|
||||
ret = pNearest->SendEvent(GUIM_MOUSE_DBLCLICK_MIDDLE, EventNameMouseMiddleDoubleClick);
|
||||
else
|
||||
ret = pNearest->SendEvent(GUIM_MOUSE_RELEASE_MIDDLE, EventNameMouseMiddleRelease);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Reset all states on all visible objects
|
||||
|
|
|
|||
|
|
@ -622,10 +622,13 @@ private:
|
|||
static const CStr EventNameRelease;
|
||||
static const CStr EventNameMouseRightPress;
|
||||
static const CStr EventNameMouseLeftPress;
|
||||
static const CStr EventNameMouseMiddlePress;
|
||||
static const CStr EventNameMouseWheelDown;
|
||||
static const CStr EventNameMouseWheelUp;
|
||||
static const CStr EventNameMouseLeftDoubleClick;
|
||||
static const CStr EventNameMouseLeftRelease;
|
||||
static const CStr EventNameMouseMiddleDoubleClick;
|
||||
static const CStr EventNameMouseMiddleRelease;
|
||||
static const CStr EventNameMouseRightDoubleClick;
|
||||
static const CStr EventNameMouseRightRelease;
|
||||
|
||||
|
|
|
|||
|
|
@ -34,11 +34,14 @@ enum EGUIMessageType
|
|||
GUIM_MOUSE_PRESS_RIGHT,
|
||||
GUIM_MOUSE_DOWN_LEFT,
|
||||
GUIM_MOUSE_DOWN_RIGHT,
|
||||
GUIM_MOUSE_PRESS_MIDDLE,
|
||||
GUIM_MOUSE_DBLCLICK_LEFT,
|
||||
GUIM_MOUSE_DBLCLICK_LEFT_ITEM, // Triggered when doubleclicking on a list item
|
||||
GUIM_MOUSE_DBLCLICK_RIGHT,
|
||||
GUIM_MOUSE_DBLCLICK_MIDDLE,
|
||||
GUIM_MOUSE_RELEASE_LEFT,
|
||||
GUIM_MOUSE_RELEASE_RIGHT,
|
||||
GUIM_MOUSE_RELEASE_MIDDLE,
|
||||
GUIM_MOUSE_WHEEL_UP,
|
||||
GUIM_MOUSE_WHEEL_DOWN,
|
||||
GUIM_SETTINGS_UPDATED, // SGUIMessage.m_Value = name of setting
|
||||
|
|
|
|||
Loading…
Reference in a new issue