ATTRIB(ListBox, focusable, float, 1)
ATTRIB(ListBox, focusedItem, int, -1)
ATTRIB(ListBox, focusedItemAlpha, float, 0.3)
+ METHOD(ListBox, setFocusedItem, void(entity, int));
ATTRIB(ListBox, mouseMoveOffset, float, -1) // let know where the cursor is when the list scrolls without moving the cursor
ATTRIB(ListBox, allowFocusSound, float, 1)
ATTRIB(ListBox, selectedItem, int, 0)
METHOD(ListBox, clickListBoxItem, void(entity, float, vector)); // item number, relative clickpos
METHOD(ListBox, doubleClickListBoxItem, void(entity, float, vector)); // item number, relative clickpos
METHOD(ListBox, setSelected, void(entity, float));
+ METHOD(ListBox, focusedItemChangeNotify, void(entity));
METHOD(ListBox, getLastFullyVisibleItemAtScrollPos, float(entity, float));
METHOD(ListBox, getFirstFullyVisibleItemAtScrollPos, float(entity, float));
me.mouseMoveOffset = pos.y;
else
{
- me.focusedItem = -1;
+ me.setFocusedItem(me, -1);
me.mouseMoveOffset = -1;
}
return 1;
else if(me.pressed == 2)
{
me.setSelected(me, me.getItemAtPos(me, me.scrollPos + pos.y));
- me.focusedItem = me.selectedItem;
+ me.setFocusedItem(me, me.selectedItem);
me.mouseMoveOffset = -1;
}
return 1;
me.pressed = 2;
// an item has been clicked. Select it, ...
me.setSelected(me, me.getItemAtPos(me, me.scrollPos + pos.y));
- me.focusedItem = me.selectedItem;
+ me.setFocusedItem(me, me.selectedItem);
}
return 1;
}
+void ListBox_setFocusedItem(entity me, int item)
+{
+ float focusedItem_save = me.focusedItem;
+ me.focusedItem = item;
+ if(focusedItem_save != me.focusedItem)
+ {
+ me.focusedItemChangeNotify(me);
+ if(me.focusedItem >= 0)
+ me.focusedItemAlpha = SKINALPHA_LISTBOX_FOCUSED;
+ }
+}
float ListBox_mouseRelease(entity me, vector pos)
{
if(me.pressed == 1)
// item dragging mode
// select current one one last time...
me.setSelected(me, me.getItemAtPos(me, me.scrollPos + pos.y));
- me.focusedItem = me.selectedItem;
+ me.setFocusedItem(me, me.selectedItem);
// and give it a nice click event
if(me.nItems > 0)
{
// by a mouse click on an item of the list
// for example showing a dialog on right click
me.pressed = 0;
- me.focusedItem = -1;
+ me.setFocusedItem(me, -1);
me.mouseMoveOffset = -1;
}
void ListBox_updateControlTopBottom(entity me)
vector oldshift, oldscale;
// we can't do this in mouseMove as the list can scroll without moving the cursor
- float focusedItem_save = me.focusedItem;
if(me.mouseMoveOffset != -1)
- me.focusedItem = me.getItemAtPos(me, me.scrollPos + me.mouseMoveOffset);
- if(me.focusedItem >= 0)
- if(focusedItem_save != me.focusedItem)
- me.focusedItemAlpha = SKINALPHA_LISTBOX_FOCUSED;
+ me.setFocusedItem(me, me.getItemAtPos(me, me.scrollPos + me.mouseMoveOffset));
if(me.needScrollToItem >= 0)
{
SUPER(ListBox).draw(me);
}
+void ListBox_focusedItemChangeNotify(entity me)
+{
+}
+
void ListBox_clickListBoxItem(entity me, float i, vector where)
{
// template method
METHOD(XonoticGametypeList, saveCvars, void(entity));
METHOD(XonoticGametypeList, keyDown, float(entity, float, float, float));
METHOD(XonoticGametypeList, clickListBoxItem, void(entity, float, vector));
+ METHOD(XonoticGametypeList, focusedItemChangeNotify, void(entity));
ATTRIB(XonoticGametypeList, realFontSize, vector, '0 0 0')
ATTRIB(XonoticGametypeList, realUpperMargin, float, 0)
{
m_play_click_sound(MENU_SOUND_SELECT);
}
+void XonoticGametypeList_focusedItemChangeNotify(entity me)
+{
+ if(me.focusedItem >= 0)
+ setZonedTooltip(me, MapInfo_Type_Description(GameType_GetID(me.focusedItem)), string_null);
+ else
+ clearTooltip(me);
+}
#endif