Xojo SourceList Example - ListBox Question

Hello,

in the Xojo Examples folder you can find the “SourceList Example”. In this example sections can be inserted (simulated) into the ListBox. The CellClick event checks whether the current line is a section or not. Accordingly, you can select lines or not. This works fine.

Now to my question, if you look at the screen capture here (https://www.dropbox.com/s/mdvc05efb5b1etx/SourceList%20Example.mp4?dl=0) once, you’ll notice like me that if you hold the mouse down and move the cursor up/down, sections will be selected as well. Is there a simple solution how to prevent this?

Thanks!

The ListBox.EnableDrag property is one possibility, but then you could no longer manually arrange the rows within the ListBox and the sections using Drag’n Drop. Other suggestions?

You exclude the row from dragging. Doesn’t really look good but it works.

if ExcludeDrag.IndexOf(RowDragged.Text) > -1 or ExcludeDrag.IndexOf(GetRoot(RowDragged).Text) > - 1 then 'do nothing RaiseEvent ShowStatusMessage(mRowBeingDragged.Text, "row") Return false else 'do the rest of the drag here. Return true end if

Thanks Beatrix,

can you please explain your code snippet a little bit? Which ListBox event does the code have to go to? Would ExcludeDrag be the row of type Section? What does the GetRoot method do and what does it look like?

The code goes to DragRow. ExcludeDrag is a list of rows that I don’t want to be dragged around (Inbox, Sent etc). The GetRoot method get’s the parent of the dragged row. I don’t want All mails -> Views dragged around where I need the root.

Sorry Beatrix, I can’t get it right with your clues. In the attachment you can find the simplified example projects, which can also be seen on the screenshot.

In this example “Xojo.Connect” and “MBS Conference” should be able to change their position between the header “1&1 Mail Basic” and “Space” via Drag’n Drop. The same applies to the entries below “AOL Mail”. Since “BKeeney Software” is the only entry below “GMX Topmail”, it cannot be moved.

Would you please insert your thoughts into the SourceList Example?

Thank you