From 35c8c77e5eec785954d31029ed84e123842e5cf1 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Thu, 11 Nov 2010 19:08:52 +0000 Subject: 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 --- src/Fl_Text_Editor.cxx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/Fl_Text_Editor.cxx') 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); -- cgit v1.2.3