Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] lost functionality, drag and drop question and caret position with StyledText

I'm not sure which version it was, but i've lost some functionality in
my RCP app moving to SWT plugin v 3.2.0.v.3232l.  I'm using TextEditor
which uses StyledText as the source viewer text widget.

Previously to using the version listed above, the user was able to do
the following:

- user selects a segment of text in the StyledText control (eg. the word
"canon").
- user drags a "text processor" from a special RCP view listing a
collection of text processors (my custom application object) from the
view onto the text editor area.
- as the user drags my object onto the selected segment of text, it
remained selected and once "dropped", that segement of text was then
processed by my application.

The important part of this is that during the drag operation when the
dragging was happening in the StyledText control, the previously
selected text remained selected.

Now, using 3.2.0.v.3232, as soon as i drag my application object onto
the styled text control, any previous selection is discarded and the
cursor in the text control moves to an insert location in relation to
the position of the mouse pointer.   I've lost the ability to "drop" my
processor onto a user text selection.

I should add that my DND transfer type is a TextTransfer which contains
a specially encoded string which i then decode on drop to fetch the
correct text processor the user selected from my RCP view.  I tried
using a custom transfer type thinking that the StyledText control only
responded this way (discarding previously selected text) with
TextTransfer types... but it didn't make a difference.

The logic for this seems to be coming from StyledTextDragAndDropEffect,
which sets the caret to a new position during dragging, and the
setCaretOffset() function clears any text selection which is where i
think my problem is coming from.

I can see the logic of this behavior, that dragging an object onto a
StyledText control is a type of insert, and the insert should happen at
the coordinates where the user performs he drop.  But why should any
previously selected text be discarded ?

Do any of you have an idea how i could preserve this previous
functionality of preserving text selection during a drag and drop
operation on a StyledText control ?

Thanks in advance,
d




Back to the top