Jump to content

Drag&Drop ListViewItem to TreeView - GUICtrlSetOnEvent mode


QA Stooge
 Share

Recommended Posts

The idea is that I'm making a tree structure of items.

If you look at the attached figure of my Battery Creation GUI...

- ListView #1 is a simple custom-made item called an "Action" (made in a different GUI) and they're stored in a data file and loaded up as ListViewItems. This works just fine.

- ListView #2 is another custom made item called a "Battery" (made in this GUI) and they're also stored in a data file and loaded up as ListViewItems. This also works just fine.

- TreeView #3 is the item in question. It is supposed to be the exploded representation of a single "Battery", which is a tree structure of "Actions". If a given Action passes, it follows the unexploded path. If it fails, and there is an expanded path (some actions have no pass/fail), it follows that instead. Sort of a binary decision tree of actions. In the end, a battery either has a fail state or a pass state. Note that batteries can include other batteries (I've already made up working code to detect and prevent infinite loops via mutual recursion or self-recursion).

So that's the final goal.

I need to make that TreeView. I need to be able to drag & drop ListViewItems from #1 and #2 into TreeView #3, and the location of the drop (in the tree) be detected via the mouse's location within the GUI.

I did some searchin in the boards, and found a couple topics, but the code included was hundreds of lines. I don't have a few days to sort it out, so if someone could point out either some basic examples, or a list of suggested AI3b functions and their role, I'd be a happy stooge.

Edited by QA Stooge
Link to comment
Share on other sites

Take a look at _GUICtrlListViewGetHotItem()

It also has an example that shows you how to use it.

To allow drag and drop you must use $WS_EX_ACCEPTFILES in the extended style parameter of the GUICreate Function.

When something is dropped onto the tree, it should let you know via the GUIGetMsg.

Also, take a look at all the UDF's (User Defined Functions) that other people have written. You can tell these apart from regular functions because they have an underscore right before the function name.

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

Allright, so far I have the ability to add ONE TreeViewItem by drag&drop.

Unable to get more than one, however. Here's a brief bit of this...

GUISetOnEvent($GUI_EVENT_DROPPED, "_TM_LVI2TVI")
...
Func _TM_LVI2TVI()
    ConsoleWrite("D&D: "&@GUI_DRAGID&" --> "&@GUI_DROPID&@CR)
    GUICtrlCreateTreeViewItem(@GUI_DRAGID&"->"&@GUI_DROPID, @GUI_DROPID)
EndFunc
Again, remember that I'm using GUICtrlSetOnEvent, and not GetMsg.

Any subsequent drag&drop after the first (which works fine) means absolutely nothing. No function is called, as if nothing ever happened.

What am I missing?

UPDATE:

I figured it out.

BUT

I have found out that I need to be able to set TreeViewItems to somehow accept drag&drop. As of now, I know how to...

- turn items into buttons to expand & such, so I can actually make a "branch" of a tree.

- drag & drop to the main path (TreeView), resulting in an expansion of the main path (extending downward)

What I DONT know how to do is...

- drag & drop onto a TreeViewItem with GUISetOnEvent enabled, and hav it recognized.

Advise? Info?

Final Update

I got activity. Proper drag & drop activity. The tree can grow.

I only need one thing now.

Is there a way to read which TreeViewItem is under the mouse cursor?

When I use GUIGetCursorInfo() all I get is the TreeView, not the TreeViewItem.

And using GUICtrlRead() only finds which one is hilighted. So that won't help.

To reiterate, is there any way to determine which TreeViewItem is under the mouse cursor?

Edited by QA Stooge
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...