diff options
author | Andrey Nazarov <skuller@skuller.net> | 2013-02-07 02:30:59 +0400 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2013-02-07 02:30:59 +0400 |
commit | 73ece29060791f940e529f3dc6f8a5a6fb497500 (patch) | |
tree | 5381c7bcf0d9f3fb426768e2153c6f5b74603a68 /src | |
parent | c10c7d64a8f047d3b9bbcc1f36cf17b4a3bb693e (diff) |
Allow decimal point in numbers-only fields.
Diffstat (limited to 'src')
-rw-r--r-- | src/client/ui/menu.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/client/ui/menu.c b/src/client/ui/menu.c index d3b4e9c..60e3233 100644 --- a/src/client/ui/menu.c +++ b/src/client/ui/menu.c @@ -434,6 +434,15 @@ static void Field_Draw(menuField_t *f) } } +static qboolean Field_TestKey(menuField_t *f, int key) +{ + if (f->generic.flags & QMF_NUMBERSONLY) { + return Q_isdigit(key) || key == '+' || key == '-' || key == '.'; + } + + return Q_isprint(key); +} + /* ================= Field_Key @@ -441,21 +450,14 @@ Field_Key */ static int Field_Key(menuField_t *f, int key) { - qboolean ret; - - ret = IF_KeyEvent(&f->field, key); - if (ret) { + if (IF_KeyEvent(&f->field, key)) { return QMS_SILENT; } - if (f->generic.flags & QMF_NUMBERSONLY) { - if (Q_isdigit(key)) { - return QMS_SILENT; - } - } else { - if (key >= 32 && key < 127) { - return QMS_SILENT; - } + + if (Field_TestKey(f, key)) { + return QMS_SILENT; } + return QMS_NOTHANDLED; } @@ -466,12 +468,10 @@ Field_Char */ static int Field_Char(menuField_t *f, int key) { - int ret; + qboolean ret; - if (f->generic.flags & QMF_NUMBERSONLY) { - if (key < '0' || key > '9') { - return QMS_BEEP; - } + if (!Field_TestKey(f, key)) { + return QMS_BEEP; } ret = IF_CharEvent(&f->field, key); |