StyledTextCtrl: enable/disable drag and drop?

Jean-Michel Fauth wrote:
> Hi all,
>
> Is it possible to disable drag and drop in a StyleTextControl?

Yes. To prevent a drag you can catch EVT_STC_START_DRAG and in the
handler call event.SetDragText(""). To prevent drops, I think you can
set a new DropTarget on the stc that doesn't accept text.

I had tried something like this before my post, bit it was not working.
See what is happening.

1) In a OnSetDragText() procedure (EVT_STC_START_DRAG),
I set event.SetDragText('').
Indeed, this somehow disables the dragging. The mouse pointer
does not change, while the text is is still selectionned.

2) I dragged the selectionned text. Nothing happens. The caret does
not follow the mouse pointer. Selection is still visible. That's ok.

3) Now I used arrows keys. The text will be unselected. Again, that's
ok. But the caret is frozen, it is impossible to move it.
The only way to unfreeze it, is to click again somewhere in the STC.

It seems that once an "startdrag event" is fired, there is automatically
a pending "DoDrop event" that is waiting to be fired. However,
adding an EVT_STC_DO_DROP does not help.

Jean-Michel Fauth, Switzerland

Jean-Michel Fauth wrote:

Jean-Michel Fauth wrote:

Hi all,

Is it possible to disable drag and drop in a StyleTextControl?

Yes. To prevent a drag you can catch EVT_STC_START_DRAG and in the handler call event.SetDragText(""). To prevent drops, I think you can set a new DropTarget on the stc that doesn't accept text.

I had tried something like this before my post, bit it was not working. See what is happening.

1) In a OnSetDragText() procedure (EVT_STC_START_DRAG), I set event.SetDragText('').
Indeed, this somehow disables the dragging. The mouse pointer
does not change, while the text is is still selectionned.

2) I dragged the selectionned text. Nothing happens. The caret does
not follow the mouse pointer. Selection is still visible. That's ok.

3) Now I used arrows keys. The text will be unselected. Again, that's
ok. But the caret is frozen, it is impossible to move it.
The only way to unfreeze it, is to click again somewhere in the STC.

It seems that once an "startdrag event" is fired, there is automatically a pending "DoDrop event" that is waiting to be fired. However,
adding an EVT_STC_DO_DROP does not help.

Please create a bug report about this so it gets on my ToDo list.

ยทยทยท

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!