mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-22 12:41:21 +00:00
Reset field cursor position when it leaves focus
This commit is contained in:
parent
b26be3ff5d
commit
c49a703467
3 changed files with 23 additions and 0 deletions
|
@ -138,6 +138,7 @@ typedef struct
|
||||||
|
|
||||||
void M_PushMenu(menuframework_s* menu);
|
void M_PushMenu(menuframework_s* menu);
|
||||||
|
|
||||||
|
void Field_ResetCursor(menuframework_s *m);
|
||||||
qboolean Field_Key(menufield_s *field, int key);
|
qboolean Field_Key(menufield_s *field, int key);
|
||||||
|
|
||||||
void Menu_AddItem(menuframework_s *menu, void *item);
|
void Menu_AddItem(menuframework_s *menu, void *item);
|
||||||
|
|
|
@ -325,12 +325,19 @@ Default_MenuKey(menuframework_s *m, int key)
|
||||||
switch (menu_key)
|
switch (menu_key)
|
||||||
{
|
{
|
||||||
case K_ESCAPE:
|
case K_ESCAPE:
|
||||||
|
if (m)
|
||||||
|
{
|
||||||
|
Field_ResetCursor(m);
|
||||||
|
}
|
||||||
|
|
||||||
M_PopMenu();
|
M_PopMenu();
|
||||||
return menu_out_sound;
|
return menu_out_sound;
|
||||||
|
|
||||||
case K_UPARROW:
|
case K_UPARROW:
|
||||||
if (m)
|
if (m)
|
||||||
{
|
{
|
||||||
|
Field_ResetCursor(m);
|
||||||
|
|
||||||
m->cursor--;
|
m->cursor--;
|
||||||
Menu_AdjustCursor(m, -1);
|
Menu_AdjustCursor(m, -1);
|
||||||
sound = menu_move_sound;
|
sound = menu_move_sound;
|
||||||
|
@ -340,6 +347,8 @@ Default_MenuKey(menuframework_s *m, int key)
|
||||||
case K_DOWNARROW:
|
case K_DOWNARROW:
|
||||||
if (m)
|
if (m)
|
||||||
{
|
{
|
||||||
|
Field_ResetCursor(m);
|
||||||
|
|
||||||
m->cursor++;
|
m->cursor++;
|
||||||
Menu_AdjustCursor(m, 1);
|
Menu_AdjustCursor(m, 1);
|
||||||
sound = menu_move_sound;
|
sound = menu_move_sound;
|
||||||
|
|
|
@ -215,6 +215,19 @@ Field_Draw(menufield_s *f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Field_ResetCursor(menuframework_s *m)
|
||||||
|
{
|
||||||
|
menucommon_s *item = Menu_ItemAtCursor(m);
|
||||||
|
|
||||||
|
if (item && item->type == MTYPE_FIELD)
|
||||||
|
{
|
||||||
|
menufield_s *f = (menufield_s *)item;
|
||||||
|
|
||||||
|
f->cursor = strlen(f->buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extern int keydown[];
|
extern int keydown[];
|
||||||
|
|
||||||
qboolean
|
qboolean
|
||||||
|
|
Loading…
Reference in a new issue