[QScintilla] Dragging Text

Baz Walter bazwal at ftml.net
Fri Dec 21 19:20:10 GMT 2007


I have found some problems with dragging and dropping text within an 
editor window. The default behaviour should be to move the dragged text 
(unless the ctrl key is also pressed), but with the current snapshot 
(2007-12-05) the text is always copied. (This is on X11 with Qt 4.3.1).

Part of the problem is caused by some recent changes in Scintilla and 
can be fixed very easily. All that is needed is to add a line to the top 
of ScintillaQt::StartDrag like this:

void ScintillaQt::StartDrag()
{
     inDragDrop = ddDragging;

...

This works for Qt3, but not for Qt4. There seems to be an additional 
problem with Qt4, which is also present in the current stable release. 
I've tracked this down to the use of QDrag.start() in 
ScintillaQt::StartDrag. According to the current Qt4 docs, this function 
is obsolete and it recommends the use of QDrag.exec() instead. However, 
when I tried patching the relevant code like this:

     // Qt::DropAction action = drag->start(actions);
     Qt::DropAction action = drag->exec(actions);

there were problems getting the text to display correctly. The dragged 
text seems to disappear when being dropped, although it /is/ being moved 
correctly, because it can be revealed by using undo/redo.

Any idea how to get this working correctly?


More information about the QScintilla mailing list