summaryrefslogtreecommitdiff
path: root/src/Fl_Input_.cxx
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2001-11-17 16:37:48 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2001-11-17 16:37:48 +0000
commit45658d7c0fa768c50f5d7fa179013833f5503a76 (patch)
tree28cc5b7cb3313bc3aa1c36a04ad861b6030b9f70 /src/Fl_Input_.cxx
parentefbe74758f28328ed734735cf0d5a631e7e28193 (diff)
Add fl_beep() function.
Don't allow non-int/float text to be pasted into an Fl_Int_Input or Fl_Float_Input widget. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1690 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Input_.cxx')
-rw-r--r--src/Fl_Input_.cxx22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/Fl_Input_.cxx b/src/Fl_Input_.cxx
index 25ba45a18..48c4c17e5 100644
--- a/src/Fl_Input_.cxx
+++ b/src/Fl_Input_.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Input_.cxx,v 1.21.2.11.2.2 2001/10/29 03:44:32 easysw Exp $"
+// "$Id: Fl_Input_.cxx,v 1.21.2.11.2.3 2001/11/17 16:37:48 easysw Exp $"
//
// Common input widget routines for the Fast Light Tool Kit (FLTK).
//
@@ -31,6 +31,7 @@
#include <FL/Fl.H>
#include <FL/Fl_Input_.H>
#include <FL/fl_draw.H>
+#include <FL/fl_ask.H>
#include <math.h>
#include <string.h>
#include <stdlib.h>
@@ -713,6 +714,23 @@ int Fl_Input_::handletext(int event, int X, int Y, int W, int H) {
const char* t = Fl::event_text();
const char* e = t+Fl::event_length();
if (type() != FL_MULTILINE_INPUT) while (e > t && isspace(*(e-1))) e--;
+ if (type() == FL_INT_INPUT) {
+ const char *p = t;
+ while ((isdigit(*p) || *p == '+' || *p == '-') && p < e)
+ p ++;
+ if (p < e) {
+ fl_beep(FL_BEEP_ERROR);
+ return 1;
+ }
+ } else if (type() == FL_FLOAT_INPUT) {
+ const char *p = t;
+ while ((isdigit(*p) || *p == '+' || *p == '-' || *p == '.') && p < e)
+ p ++;
+ if (p < e) {
+ fl_beep(FL_BEEP_ERROR);
+ return 1;
+ }
+ }
return replace(position(), mark(), t, e-t);}
default:
@@ -821,5 +839,5 @@ Fl_Input_::~Fl_Input_() {
}
//
-// End of "$Id: Fl_Input_.cxx,v 1.21.2.11.2.2 2001/10/29 03:44:32 easysw Exp $".
+// End of "$Id: Fl_Input_.cxx,v 1.21.2.11.2.3 2001/11/17 16:37:48 easysw Exp $".
//