diff options
| author | Bill Spitzak <spitzak@gmail.com> | 2000-02-22 00:56:53 +0000 |
|---|---|---|
| committer | Bill Spitzak <spitzak@gmail.com> | 2000-02-22 00:56:53 +0000 |
| commit | 666d0412243ce671dc53ddeb3a29b5c866f5066b (patch) | |
| tree | 5b13c52d66ead503ced98398528274ae91867526 /src/Fl_Input.cxx | |
| parent | b583a643deeaf0a21dac5ee5a2ae0f84f9648dad (diff) | |
Fixed the changes I made yesterday so that int/float input fields do not
eat Alt+letter key combinations.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1009 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Input.cxx')
| -rw-r--r-- | src/Fl_Input.cxx | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/src/Fl_Input.cxx b/src/Fl_Input.cxx index ab6947eb5..cef2a092f 100644 --- a/src/Fl_Input.cxx +++ b/src/Fl_Input.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Input.cxx,v 1.10.2.6 2000/02/21 10:29:58 bill Exp $" +// "$Id: Fl_Input.cxx,v 1.10.2.7 2000/02/22 00:56:53 bill Exp $" // // Input widget for the Fast Light Tool Kit (FLTK). // @@ -62,32 +62,26 @@ int Fl_Input::handle_key() { char ascii = Fl::event_text()[0]; - // Insert characters into numeric fields after checking for legality: - if (type() == FL_FLOAT_INPUT) { + int del; + if (Fl::compose(del)) { - // This could be improved to make sure characters are only inserted - // at legal positions... - if (ascii && strchr("0123456789.eE+-", ascii)) - return replace(position(), mark(), &ascii, 1); - - } else if (type() == FL_INT_INPUT) { - - // Somewhat more complicated so that "0x12ab" hex can be typed - if (!position() && (ascii == '+' || ascii == '-') - || (ascii >= '0' && ascii <= '9') - || (position()==1 && index(0)=='0' && (ascii=='x' || ascii == 'X')) - || (position()>1 && index(0)=='0' && (index(1)=='x'||index(1)=='X') - && (ascii>='A'&& ascii<='F' || ascii>='a'&& ascii<='f'))) - return replace(position(), mark(), &ascii, 1); - - } else { - // normal input fields use compose processing: - int del; - if (Fl::compose(del)) { - replace(position(), del ? position()-del : mark(), - Fl::event_text(), Fl::event_length()); + // Insert characters into numeric fields after checking for legality: + if (type() == FL_FLOAT_INPUT || type() == FL_INT_INPUT) { + Fl::compose_reset(); // ignore any foreign letters... + // This is complex to allow "0xff12" hex to be typed: + if (!position() && (ascii == '+' || ascii == '-') || + (ascii >= '0' && ascii <= '9') || + (position()==1 && index(0)=='0' && (ascii=='x' || ascii == 'X')) || + (position()>1 && index(0)=='0' && (index(1)=='x'||index(1)=='X') + && (ascii>='A'&& ascii<='F' || ascii>='a'&& ascii<='f')) || + type()==FL_FLOAT_INPUT && ascii && strchr(".eE+-", ascii)) + replace(position(), mark(), &ascii, 1); return 1; } + + replace(position(), del ? position()-del : mark(), + Fl::event_text(), Fl::event_length()); + return 1; } switch (Fl::event_key()) { @@ -259,5 +253,5 @@ Fl_Input::Fl_Input(int x, int y, int w, int h, const char *l) } // -// End of "$Id: Fl_Input.cxx,v 1.10.2.6 2000/02/21 10:29:58 bill Exp $". +// End of "$Id: Fl_Input.cxx,v 1.10.2.7 2000/02/22 00:56:53 bill Exp $". // |
