summaryrefslogtreecommitdiff
path: root/src/Fl_Text_Editor.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2010-11-11 19:08:52 +0000
committerMatthias Melcher <fltk@matthiasm.com>2010-11-11 19:08:52 +0000
commit35c8c77e5eec785954d31029ed84e123842e5cf1 (patch)
tree1afac8bc795462a82e3de05fd79cfdcd5a4f9249 /src/Fl_Text_Editor.cxx
parent473d8af1a465ff9b30570fd9f1ed690a30b5fbb8 (diff)
This should fix all remaining issues with Fl_Text_*. Wrapping is no pixel aligned. Pressing up and down will be pixle bound. A few crashes removed (we still crash with faulty UTF-8svn diff | grep Index:). Fixed blinking selection when outside the widget. Added dnd sending and receiving.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7819 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Text_Editor.cxx')
-rw-r--r--src/Fl_Text_Editor.cxx22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/Fl_Text_Editor.cxx b/src/Fl_Text_Editor.cxx
index 62b959d22..5827f8027 100644
--- a/src/Fl_Text_Editor.cxx
+++ b/src/Fl_Text_Editor.cxx
@@ -546,6 +546,8 @@ void Fl_Text_Editor::maybe_do_callback() {
}
int Fl_Text_Editor::handle(int event) {
+ static int dndCursorPos;
+
if (!buffer()) return 0;
switch (event) {
@@ -590,7 +592,7 @@ int Fl_Text_Editor::handle(int event) {
if (Fl::event_button() == 2) {
// don't let the text_display see this event
if (Fl_Group::handle(event)) return 1;
- dragType = -1;
+ dragType = DRAG_NONE;
Fl::paste(*this, 0);
Fl::focus(this);
set_changed();
@@ -607,6 +609,24 @@ int Fl_Text_Editor::handle(int event) {
return 1;
}
break;
+
+ // Handle drag'n'drop attempt by the user. This is a simplified
+ // implementation which allows dnd operations onto the scroll bars.
+ case FL_DND_ENTER: // save the current cursor position
+ if (Fl::visible_focus() && handle(FL_FOCUS))
+ Fl::focus(this);
+ show_cursor(mCursorOn);
+ dndCursorPos = insert_position();
+ /* fall through */
+ case FL_DND_DRAG: // show a temporary insertion cursor
+ insert_position(xy_to_position(Fl::event_x(), Fl::event_y(), CURSOR_POS));
+ return 1;
+ case FL_DND_LEAVE: // restore original cursor
+ insert_position(dndCursorPos);
+ return 1;
+ case FL_DND_RELEASE: // keep insertion cursor and wait for the FL_PASTE event
+ buffer()->unselect(); // FL_PASTE must not destroy current selection!
+ return 1;
}
return Fl_Text_Display::handle(event);