forked from pyrite-dev/milsko
number
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@247 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
parent
9fc580eeb2
commit
3e2d129b93
3 changed files with 19 additions and 6 deletions
|
|
@ -183,10 +183,9 @@ void MwLLNextEvent(MwLL handle) {
|
||||||
MwLLDispatch(handle, move, &p);
|
MwLLDispatch(handle, move, &p);
|
||||||
} else if(ev.type == KeyPress) {
|
} else if(ev.type == KeyPress) {
|
||||||
int n = -1;
|
int n = -1;
|
||||||
KeySym sym = XLookupKeysym(&ev.xkey, 0);
|
char str[512];
|
||||||
char* str = XKeysymToString(sym);
|
KeySym sym;
|
||||||
|
XLookupString(&ev.xkey, str, 512, &sym, NULL);
|
||||||
if(strcmp(str, "space") == 0) str = " ";
|
|
||||||
|
|
||||||
/* HACK: this is bad, you can guess why */
|
/* HACK: this is bad, you can guess why */
|
||||||
if(strlen(str) == 1) {
|
if(strlen(str) == 1) {
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ static void draw(MwWidget handle) {
|
||||||
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||||
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
||||||
const char* str = MwGetText(handle, MwNtext);
|
const char* str = MwGetText(handle, MwNtext);
|
||||||
|
if(str == NULL) str = "";
|
||||||
|
|
||||||
r.x = 0;
|
r.x = 0;
|
||||||
r.y = 0;
|
r.y = 0;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,20 @@ static void draw(MwWidget handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void key(MwWidget handle, int code) {
|
static void key(MwWidget handle, int code) {
|
||||||
MwEntryClass->key(handle, code);
|
MwEntry e = handle->internal;
|
||||||
|
const char* str = MwGetText(handle, MwNtext);
|
||||||
|
int ok = 0;
|
||||||
|
if(str == NULL) str = "";
|
||||||
|
|
||||||
|
if(code == '-' && e->cursor == 0 && strchr(str, (int)'-') == NULL) {
|
||||||
|
ok = 1;
|
||||||
|
} else if('0' <= code && code <= '9') {
|
||||||
|
ok = 1;
|
||||||
|
} else if(code == '.' && strchr(str, (int)'.') == NULL) {
|
||||||
|
ok = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ok) MwEntryClass->key(handle, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwClassRec MwNumberEntryClassRec = {
|
MwClassRec MwNumberEntryClassRec = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue