I’ve been working on a script to manage materials (thread here:http://forums.cgsociety.org/showthread.php?f=98&t=629065 ) and I was constantly annoyed by the impossibility of assigning a material to an object by drag and drop while outside the Material Editor.
However I think I might have come up with a way to work around this limitation. Here’s the basic idea:
-You start by dragging from somewhere, in my case a node in a .net treeView. As the dragging starts you store the material you are going to apply to the object in a variable (the material is of course selected based on which node is dragged).
-When the mouse leaves the treeView a onMouseLeave event is triggered, which then triggers a mouse tool.
-The mouse tool waits for the user to un-click the mouse button and when this happens, looks for the object under the mouse and then applies to it the material that was previously stored.
This is of course a lot more complicated than it sounds. For example there is no event in a mouse tool to detect that the left mouse button has gone up. My first attempt here was to use the ON freeMove event and continously check the mouse button state. This failed miserably as the mouse.buttonStates property only detects key changes made inside the viewport and thus failed to realize that the left mouse button was allready pressed when the cursor entred the viewport.
Currently I have fixed this using some .NET to check the mouse button state. While not really perfect, as the user has to move the mouse AFTER the button has been released for the event to launch, it is certanly a step in the right direction.
If anyone is interested I’ll try to come up with a code example (right now it’s too tangled with the script to be easy to understand).