Don't paste if there is no data to paste.

Change the cursor in Fl_File_Input based on the location in the field.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2557 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet
2002-07-30 18:10:03 +00:00
parent 7bde142766
commit 1cea00ad00
3 changed files with 34 additions and 13 deletions
+2
View File
@@ -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.
+26 -11
View File
@@ -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);
if (Fl_Input::handle(event)) {
damage(FL_DAMAGE_BAR);
return 1;
} else return 0;
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);
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 $".
//
+6 -2
View File
@@ -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 $".
//