Handle double-clicks on list elements better. Patch by elexis.
Fixes #3574 This was SVN commit r17274.
This commit is contained in:
parent
721c731567
commit
70164a02c4
@ -173,7 +173,7 @@
|
||||
<object name="gamesBox" style="ModernList" sprite_asc="ModernArrowDown" default_column="name" sprite_desc="ModernArrowUp" sprite_not_sorted="ModernNotSorted" type="olist" sortable="true" size="0 25 100% 48%" font="sans-stroke-13">
|
||||
<action on="SelectionChange">updateGameSelection();</action>
|
||||
<action on="SelectionColumnChange">updateGameListOrderSelection();</action>
|
||||
<action on="mouseleftdoubleclick">joinSelectedGame();</action>
|
||||
<action on="mouseleftdoubleclickitem">joinSelectedGame();</action>
|
||||
<def id="name" color="0 60 0" width="27%">
|
||||
<translatableAttribute id="heading">Name</translatableAttribute>
|
||||
</def>
|
||||
|
@ -64,7 +64,7 @@
|
||||
|
||||
<action on="SelectionChange">displayReplayDetails();</action>
|
||||
<action on="SelectionColumnChange">displayReplayList();</action>
|
||||
<action on="mouseleftdoubleclick">startReplay();</action>
|
||||
<action on="mouseleftdoubleclickitem">startReplay();</action>
|
||||
|
||||
<!-- Columns -->
|
||||
<!-- We have to call one "name" as the GUI expects one. -->
|
||||
|
@ -44,6 +44,8 @@ CGUI
|
||||
|
||||
ERROR_TYPE(GUI, JSOpenFailed);
|
||||
|
||||
extern const double SELECT_DBLCLICK_RATE;
|
||||
|
||||
/**
|
||||
* Contains a list of values for new defaults to objects.
|
||||
*/
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
|
||||
CList::CList()
|
||||
: m_Modified(false)
|
||||
: m_Modified(false), m_PrevSelectedItem(-1), m_LastItemClickTime(0)
|
||||
{
|
||||
// Add sprite_disabled! TODO
|
||||
|
||||
@ -111,7 +111,7 @@ void CList::SetupText()
|
||||
SGUIText* text = new SGUIText();
|
||||
|
||||
*text = GetGUI()->GenerateText(pList->m_Items[i], font, width, buffer_zone, this);
|
||||
|
||||
text->
|
||||
m_ItemsYPositions[i] = buffered_y;
|
||||
buffered_y += text->m_Size.cy;
|
||||
|
||||
@ -216,6 +216,11 @@ void CList::HandleMessage(SGUIMessage& Message)
|
||||
CStrW soundPath;
|
||||
if (g_SoundManager && GUI<CStrW>::GetSetting(this, "sound_selected", soundPath) == PSRETURN_OK && !soundPath.empty())
|
||||
g_SoundManager->PlayAsUI(soundPath.c_str(), false);
|
||||
|
||||
if (timer_Time() - m_LastItemClickTime < SELECT_DBLCLICK_RATE && set == m_PrevSelectedItem)
|
||||
this->SendEvent(GUIM_MOUSE_DBLCLICK_LEFT_ITEM, "mouseleftdoubleclickitem");
|
||||
m_LastItemClickTime = timer_Time();
|
||||
m_PrevSelectedItem = set;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -108,6 +108,12 @@ protected:
|
||||
private:
|
||||
// Whether the list's items have been modified since last handling a message.
|
||||
bool m_Modified;
|
||||
|
||||
// Used for doubleclick registration
|
||||
int m_PrevSelectedItem;
|
||||
|
||||
// Last time a click on an item was issued
|
||||
double m_LastItemClickTime;
|
||||
};
|
||||
|
||||
#endif // INCLUDED_CLIST
|
||||
|
@ -64,6 +64,7 @@ enum EGUIMessageType
|
||||
GUIM_MOUSE_DOWN_LEFT,
|
||||
GUIM_MOUSE_DOWN_RIGHT,
|
||||
GUIM_MOUSE_DBLCLICK_LEFT,
|
||||
GUIM_MOUSE_DBLCLICK_LEFT_ITEM, // Triggered when doubleclicking on a list item
|
||||
GUIM_MOUSE_DBLCLICK_RIGHT,
|
||||
GUIM_MOUSE_RELEASE_LEFT,
|
||||
GUIM_MOUSE_RELEASE_RIGHT,
|
||||
|
Loading…
Reference in New Issue
Block a user