More fixes to the text editing to make the NT users happy.
With all the recent check-ins, the result is that text editing is a combination of the best parts of "CUA" and X/Motif text editing (in my opinion). It mostly acts like CUA with these additions: 1. Clicking in a field the first time selects the entire field (this is a necessary modification so that it works in point-to-type window managers and still looks like Windoze, in Windoze it appears that all text fields are switched to all-selected when the window is "activated"). 2. The middle mouse button acts like the left one and *then* does "paste". Unlike Motif you can replace text by selecting it with the middle mouse button. 3. *drag* of the left mouse button does "copy". Unlike Motif, other methods of selecting text (like double-click) does not do "copy". git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@807 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
936b75f917
commit
c3bd173a57
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// "$Id: Fl_Input.cxx,v 1.10.2.3 1999/10/15 09:01:43 bill Exp $"
|
// "$Id: Fl_Input.cxx,v 1.10.2.4 1999/10/30 20:21:29 bill Exp $"
|
||||||
//
|
//
|
||||||
// Input widget for the Fast Light Tool Kit (FLTK).
|
// Input widget for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
@ -279,7 +279,6 @@ int Fl_Input::handle_key() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Fl_Input::handle(int event) {
|
int Fl_Input::handle(int event) {
|
||||||
static char first_click;
|
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
||||||
@ -312,28 +311,24 @@ int Fl_Input::handle(int event) {
|
|||||||
return handle_key();
|
return handle_key();
|
||||||
|
|
||||||
case FL_PUSH:
|
case FL_PUSH:
|
||||||
compose = 0;
|
|
||||||
first_click = 0;
|
|
||||||
if (Fl::focus() != this) {
|
if (Fl::focus() != this) {
|
||||||
Fl::focus(this);
|
Fl::focus(this);
|
||||||
handle(FL_FOCUS);
|
handle(FL_FOCUS);
|
||||||
// Windoze-style: select everything on first click:
|
// Windoze-style: select everything on first click:
|
||||||
if (type() != FL_MULTILINE_INPUT) {
|
if (type() != FL_MULTILINE_INPUT) {
|
||||||
first_click = 1;
|
|
||||||
position(size(), 0); // select everything
|
position(size(), 0); // select everything
|
||||||
Fl::event_is_click(0); // prevents next click from being a double click
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// don't remove selection when pasting in a replacement:
|
compose = 0;
|
||||||
if (Fl::event_button() == 2 && mark() != position()) return 1;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FL_RELEASE:
|
case FL_RELEASE:
|
||||||
if (Fl::event_button() == 2) {
|
if (Fl::event_button() == 2) {
|
||||||
Fl::event_is_click(0); // stop double click from picking a word
|
Fl::event_is_click(0); // stop double click from picking a word
|
||||||
Fl::paste(*this);
|
Fl::paste(*this);
|
||||||
} else if (!first_click) {
|
} else if (!Fl::event_is_click()) {
|
||||||
|
// copy drag-selected text to the clipboard.
|
||||||
copy();
|
copy();
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -350,5 +345,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.3 1999/10/15 09:01:43 bill Exp $".
|
// End of "$Id: Fl_Input.cxx,v 1.10.2.4 1999/10/30 20:21:29 bill Exp $".
|
||||||
//
|
//
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// "$Id: Fl_Input_.cxx,v 1.21.2.1 1999/10/15 09:01:44 bill Exp $"
|
// "$Id: Fl_Input_.cxx,v 1.21.2.2 1999/10/30 20:21:30 bill Exp $"
|
||||||
//
|
//
|
||||||
// Common input widget routines for the Fast Light Tool Kit (FLTK).
|
// Common input widget routines for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
@ -352,7 +352,7 @@ void Fl_Input_::handle_mouse(int X, int Y,
|
|||||||
p = e;
|
p = e;
|
||||||
if (e >= value_+size_) break;
|
if (e >= value_+size_) break;
|
||||||
}
|
}
|
||||||
const char *l, *r, *t; double f0 = 0;
|
const char *l, *r, *t; double f0 = Fl::event_x()-X+xscroll_;
|
||||||
for (l = p, r = e; l<r; ) {
|
for (l = p, r = e; l<r; ) {
|
||||||
double f;
|
double f;
|
||||||
t = l+(r-l+1)/2;
|
t = l+(r-l+1)/2;
|
||||||
@ -387,6 +387,14 @@ void Fl_Input_::handle_mouse(int X, int Y,
|
|||||||
while (!wordboundary(newpos)) newpos--;
|
while (!wordboundary(newpos)) newpos--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// if the multiple click does not increase the selection, revert
|
||||||
|
// to single-click behavior:
|
||||||
|
if (!drag && (mark() > position() ?
|
||||||
|
(newmark >= position() && newpos <= mark()) :
|
||||||
|
(newmark >= mark() && newpos <= position()))) {
|
||||||
|
Fl::event_clicks(0);
|
||||||
|
newmark = newpos = l-value();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
position(newpos, newmark);
|
position(newpos, newmark);
|
||||||
}
|
}
|
||||||
@ -737,5 +745,5 @@ Fl_Input_::~Fl_Input_() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: Fl_Input_.cxx,v 1.21.2.1 1999/10/15 09:01:44 bill Exp $".
|
// End of "$Id: Fl_Input_.cxx,v 1.21.2.2 1999/10/30 20:21:30 bill Exp $".
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user