Help with DragItem in MouseDown event

Trying to drag/drop values from one combobox to another but the original functionality of combo gets munged when it hit’s d.drag.

For comboboxes added the following to the MouseDown event:
dim d as DragItem
d = new DragItem(self,me.left,me.top,me.width,me.height)
d.Text = str(me.listindex)
d.drag

I can drag to another combobox perfectly, awesome! What I’m not sure how to is get the combobox to function normally when the mouse button isn’t being held down. The dropdown opens afterward on the original combobox dragged from which I’d like to close. Also even if not dragging or dropping, say user just clicked on it to enter text the combo drops down but then user have to click multiple times to get value to take and you cannot type in value as the combobox seems to get into a goofy state.

Tried basically the same thing between textfields…
dim d as DragItem
d = new DragItem(self,me.left,me.top,me.width,me.height)
d.Text = me.text
d.drag

Drag/Drop values works just fine but cannot get the Textfield to function normally again. Whenever moused clicked you cannot enter text and moving the mouse around the textfield just highlights the text like the mouse button is still being pressed down. Only way can type in the textfields is if I tab into them rather than clicking on them.

Any guidance on how to utilizing drag/drop without goofing the original control entry rules would be appreciated!

I’m new to Xojo but I’d try using the Drag / Drop event handlers instead of MouseDown.

I’m new at this as well… drag/drop was easy in vb.net but not quite getting it in Xojo. Is there an event handler that can be used to initiate a drag? For comboboxes and text boxes you have DragEnter, DragOver, DragExit which only fire after the drag has already been initiated via something like DragItem, then the DropObject fires when you release the mouse button. Thanks!

dim d as DragItem
d = new DragItem(self,me.left,me.top,me.width,me.height)
d.Text = me.text
d.drag
return true

Ok Jason, I figured it out. In the open event for each ComboBox enter

me.AcceptTextDrop.

In the DropObject event enter

If Obj.TextAvailable then
Me.text=Obj.Text //enters text into field
Me.AddRow(Obj.Text) //Appends text to list
End if

It should be possible to get the DragItem from the DragExit event but unfortunately DragExit and DropObject do not fire when they should (see <https://xojo.com/issue/23684>).

On Mac Carbon builds it never seemed to matter as it just worked anyway. Cocoa and Windows are another story. Particularly with ComboBoxes it causes the control to get into a goofy state, as Jason says. I have used the same code as Tim and Jason to get the DragItem from the MouseDown event but instead Return False so that the event is passed on. This seems to work a bit better for Cocoa and particularly for Windows, as the ComboBox remains responsive. And you need to put me.AcceptTextDrop in the Open event of the receiving control.

Spot on Richard, finding the same… Carbon is fine, Windows keeps me banging my head on the desk… and will keep an eye on 23684. Unfortunate the ComboBox just looses it mind… Text boxes seem to be problematic as well with being able to type on Windows when drag/drop is enabled unless they get their focus via tab. Just in a mix were both controls work fine without drag/drop, both controls work fine with just drag/drop, but allowing drag/drop plus input argh. Oh well, on to another fight for now, was hoping there was something obvious I was missing being new to Xojo but does not appear to be the case and will hash out some other work-around. Appreciate everyone’s responses.