mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-21 19:31:13 +00:00
CTRL+l,c,x,v shortcuts for menu input fields
This commit is contained in:
parent
8d5d86cbaf
commit
b26be3ff5d
2 changed files with 52 additions and 2 deletions
|
@ -1420,7 +1420,8 @@ Key_Event(int key, qboolean down, qboolean special)
|
|||
/* FIXME: Better way to do CTRL+<key> actions in the console?
|
||||
special should be set to true in this case.
|
||||
*/
|
||||
if (keydown[K_CTRL] && IsInConsole() &&
|
||||
if (keydown[K_CTRL] &&
|
||||
(IsInConsole() || cls.key_dest == key_menu) &&
|
||||
key >= 'a' && key <= 'z')
|
||||
{
|
||||
special = true;
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
#include "../header/client.h"
|
||||
#include "header/qmenu.h"
|
||||
|
||||
void IN_GetClipboardText(char *out, size_t n);
|
||||
int IN_SetClipboardText(const char *s);
|
||||
|
||||
static void Action_Draw(menuaction_s *a);
|
||||
static void Menu_DrawStatusBar(const char *string);
|
||||
static void MenuList_Draw(menulist_s *l);
|
||||
|
@ -217,7 +220,53 @@ extern int keydown[];
|
|||
qboolean
|
||||
Field_Key(menufield_s *f, int key)
|
||||
{
|
||||
char txt[2];
|
||||
char txt[256];
|
||||
|
||||
if (keydown[K_CTRL])
|
||||
{
|
||||
if (key == 'l')
|
||||
{
|
||||
*f->buffer = '\0';
|
||||
f->cursor = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (key == 'c' || key == 'x')
|
||||
{
|
||||
if (*f->buffer != '\0')
|
||||
{
|
||||
if (IN_SetClipboardText(f->buffer))
|
||||
{
|
||||
Com_Printf("Copying menu field to clipboard failed.\n");
|
||||
}
|
||||
else if (key == 'x')
|
||||
{
|
||||
*f->buffer = '\0';
|
||||
f->cursor = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (key == 'v')
|
||||
{
|
||||
IN_GetClipboardText(txt, sizeof(txt));
|
||||
|
||||
if (*txt != '\0')
|
||||
{
|
||||
if ((f->generic.flags & QMF_NUMBERSONLY) && !Q_strisnum(txt))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
f->cursor += Q_strins(f->buffer, txt, f->cursor, f->length);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (key)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue