summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES2
-rw-r--r--src/Fl_File_Input.cxx37
-rw-r--r--src/Fl_Input_.cxx8
3 files changed, 34 insertions, 13 deletions
diff --git a/CHANGES b/CHANGES
index 9eb4b9f3d..5845ab913 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
CHANGES IN FLTK 1.1.0
- Documentation updates.
+ - Fl_Input_ could crash if it received an empty paste
+ event.
- The mouse pointer now changes to the I beam
(FL_CURSOR_INSERT) when moved over an input field or
text widget.
diff --git a/src/Fl_File_Input.cxx b/src/Fl_File_Input.cxx
index b646e4571..c80265227 100644
--- a/src/Fl_File_Input.cxx
+++ b/src/Fl_File_Input.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_File_Input.cxx,v 1.1.2.3 2002/05/24 14:25:04 easysw Exp $"
+// "$Id: Fl_File_Input.cxx,v 1.1.2.4 2002/07/30 18:10:03 easysw Exp $"
//
// File_Input header file for the Fast Light Tool Kit (FLTK).
//
@@ -180,15 +180,29 @@ Fl_File_Input::handle(int event) // I - Event
{
// printf("handle(event = %d)\n", event);
- if ((event == FL_PUSH || event == FL_RELEASE || event == FL_DRAG) &&
- (Fl::event_y() < (y() + DIR_HEIGHT) || pressed_ >= 0)) {
- return handle_button(event);
- }
+ switch (event) {
+ case FL_MOVE :
+ case FL_ENTER :
+ if (Fl::event_y() < (y() + DIR_HEIGHT)) fl_cursor(FL_CURSOR_DEFAULT);
+ else fl_cursor(FL_CURSOR_INSERT);
+
+ return 1;
+
+ case FL_PUSH :
+ case FL_RELEASE :
+ case FL_DRAG :
+ if (Fl::event_y() < (y() + DIR_HEIGHT) || pressed_ >= 0) return handle_button(event);
+
+ return Fl_Input::handle(event);
- if (Fl_Input::handle(event)) {
- damage(FL_DAMAGE_BAR);
- return 1;
- } else return 0;
+ default :
+ if (Fl_Input::handle(event)) {
+ damage(FL_DAMAGE_BAR);
+ return 1;
+ }
+
+ return 0;
+ }
}
@@ -201,7 +215,7 @@ Fl_File_Input::handle_button(int event) // I - Event
{
int i, // Looping var
X; // Current X position
- const char *start, // Start of path component
+ char *start, // Start of path component
*end; // End of path component
char newvalue[1024]; // New value
@@ -242,6 +256,7 @@ Fl_File_Input::handle_button(int event) // I - Event
if (i < 0) {
// Found the end; truncate the value and update the buttons...
+ *start = '\0';
value(newvalue, start - newvalue);
// Then do the callbacks, if necessary...
@@ -253,5 +268,5 @@ Fl_File_Input::handle_button(int event) // I - Event
//
-// End of "$Id: Fl_File_Input.cxx,v 1.1.2.3 2002/05/24 14:25:04 easysw Exp $".
+// End of "$Id: Fl_File_Input.cxx,v 1.1.2.4 2002/07/30 18:10:03 easysw Exp $".
//
diff --git a/src/Fl_Input_.cxx b/src/Fl_Input_.cxx
index c27752dc1..d270c8b07 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.17 2002/07/30 15:10:32 easysw Exp $"
+// "$Id: Fl_Input_.cxx,v 1.21.2.11.2.18 2002/07/30 18:10:03 easysw Exp $"
//
// Common input widget routines for the Fast Light Tool Kit (FLTK).
//
@@ -694,11 +694,15 @@ int Fl_Input_::handletext(int event, int X, int Y, int W, int H) {
return 1;
case FL_PASTE: {
+ // Don't allow pastes into readonly widgets...
if (readonly()) {
fl_beep(FL_BEEP_ERROR);
return 1;
}
+ // See if we have anything to paste...
+ if (!Fl::event_text() || !Fl::event_length()) return 1;
+
// strip trailing control characters and spaces before pasting:
const char* t = Fl::event_text();
const char* e = t+Fl::event_length();
@@ -844,5 +848,5 @@ Fl_Input_::~Fl_Input_() {
}
//
-// End of "$Id: Fl_Input_.cxx,v 1.21.2.11.2.17 2002/07/30 15:10:32 easysw Exp $".
+// End of "$Id: Fl_Input_.cxx,v 1.21.2.11.2.18 2002/07/30 18:10:03 easysw Exp $".
//