[Closed] Drag and Drop
Any one if it is possible with just a Max Script solution to setup a drag and drop from a DotNet UI to the material editor?
Not at Max so I can’t test it at the moment.
to have a drop event and to get dragging data you need another .net UI control.
so there are ideas:
#1
on drag begin add new transparent .net form on top of material editor. this form can receive drop event, and get dragging data and point where data was dropped.
after that you can find what part (element, control, etc.) of editor is under this point. if it fits you dropping goal do what you want.
after data was dropped or drag was canceled you have to destroy that transparent window.
in theory it has to work.
#2
other idea is to use native window that can capture the material editor (use its handle) and receive all its messages including mouse press and release events.
this solution needs c# code (compiled on-the-fly assembly for example).
solution #2 i’ve used to drag and drop from .net ui to max viewport
Nice, second sounds cleaner. I will have a closer look at it. Thanks for the info.
Interesting problem.
So if I drag and drop onto the material editor, say a multisub material. I can get the button using the first method that I dropped on but how can I figure out what that button is connected to.
- Drop on material editor.
- Find the button dropped on.
- Was it a material slot?? and if so which slot?
Looks like slate is a bit of a black box as well. Can’t even find the handle for it.
where do you expect to drop on? if you want to drop on slots area you can “cover” with .net form only this area. in material editor its always the same size but might have a slide (vertical and horizontal shift). as i remember it can be 3×2, 5×3, and 6×4. you can get this sample option from current ini file.
to get a scroll bar value (position) you can call GetScrollPos (needs assembly).
so if you know size of slots area, dimension, and scroll values you can find a slot under mouse point.
(sorry i don’t have max right now and can’t give a snippet)
ha! there is another idea. as i remember every time when you click on a slot of material editor the system fires #mtlRefAdded event and makes this slot active. it maybe easier to use this fact? just check that you are still in “dragging mode” this moment.
Interesting. Second option again might be the best if it works. What a huge pain in the ass. I want to be able to drag and drop materials from a custom browser to slots in a multisub material mainly in the Compact material editor. Would like it to be able to work in Slate as well but that is a bit of a mystery at this point.
Just discovering which window is the material editor it self is a bit of guess work in it self. I can use the title of it but that can change, don’t think it does but it isn’t 100% reliable.
With Slate…
UIAccessor.GetPopupDialogs()
Does not return it.
Something else that is interesting.
for h in windows.getChildrenHWND #max do format “%
” h –Does not return compact Mat Editor or Slate.
UIAccessor.GetPopupDialogs() – Returns compact mat editor but not Slate.
What the hell am I missing?
for h in windows.getChildrenHWND 0 do format "%
" h
has to find both material editors
these dialogs probably not child windows of max