PDA

View Full Version : materialBrowseDlg() question


MarcoBrunetta
04-07-2009, 02:54 PM
I've noticed that when using the materialBrowseDl() function, both pressing the cancel button and choosing "NONE" (if the #incNone option was used) return undefined.
I'm trying to reproduce a mapButton outside the material editor using a normal button that calls the materialBrowseDl() when it's pressed. Yet having both return undefined results in the script being incapable of recognizing when the user wants to REMOVE the map (choosing "None"), and when he wants to cancel the change of map (by hitting the cancel button).

Any thoughts/workarounds ?

ZeBoxx2
04-07-2009, 04:06 PM
short of not including #incNone and allowing the user to clear via ctrl/shift/alt-click or a right-click(+popup menu) option?

..no. Doesn't seem to be much of a way to detect which the user chose - Cancel vs the None map. Would have been great if picking the map would return None (which is of class UndefinedClass and == undefined anyway, but could be cast to string to check, I suppose)

Edit: out of curiosity... why aren't you using a mapbutton, exactly? :o

MarcoBrunetta
04-07-2009, 04:13 PM
Yhea... I have a workaround like that in place. I was just wondering if I was missing something.

Thanks!

EDIT: because the goddamned mapButton won't let me do a drag and drop outside of the material editor. I'm hoping I'll be able to work something out with a .net button... hopefully... yes... I'm naive like that...

ZeBoxx2
04-07-2009, 04:24 PM
Ahhh, that.. yeah, I'm just not seeing how .NET is going to help, sadly :| But! Good luck to ye - if you do crack it, I'll buy you a case of beer.. or.. coke.. something :)

MarcoBrunetta
04-07-2009, 04:32 PM
Ajaa! A challenge! You'r on mister.

This is what I'm toying with btw:
http://i42.tinypic.com/91dv11.jpg

And yhea... I realize the inherent futility of redesigning the GUI for the Material Editor. It's mostly an exercise... trying to figure out how it could be better I guess.

Opinions welcomed.

ZeBoxx2
04-07-2009, 06:19 PM
looks great - though rewriting the entire medit I think disqualifies you from the case of beer ;)

An integrated treeview is awesome, for sure. Having both dialogs open at all is quite the annoyance.

MarcoBrunetta
04-07-2009, 06:57 PM
looks great - though rewriting the entire medit I think disqualifies you from the case of beer ;)


Damn....there goes my whole incentive...

Anyways, I poked around .NET a bit, and the standard button control has an .AllowDrop property and all the required methods so it should be theoretically possible to have some manner of drag and dropping at will.

Of course given my natural inclination to have no clue of how to make stuff in .NET work, it will probably take me like 3 years yo figure out exactly how.

Damn... I could have used that case of beer

MarcoBrunetta
04-07-2009, 08:10 PM
3 went quickly thanks to my time machine.

Here's a sample code of 3 .NET buttons set up so you can drag and drop their text. It should be easy enough to understand in case somebody needs to use something like that.

rollout testRoll "TEST"
(
dotnetcontrol theButton1 "System.Windows.Forms.Button"
dotnetcontrol theButton2 "System.Windows.Forms.Button" pos:(theButton1.pos+[0,30])
dotnetcontrol theButton3 "System.Windows.Forms.Button" pos:(theButton2.pos+[0,30])

local storeText
local sourceButton

ON theButton1 mouseDown arg DO
(
IF arg.button == arg.button.left DO
(
print "draggin started on Button 1"
storeText = theButton1.text
sourceButton = 1
local dragDropEffect = dotNetClass "System.Windows.Forms.DragDropEffects"
theButton1.doDragDrop theButton1.text dragDropEffect.Move
)
)

ON theButton2 mouseDown arg DO
(
IF arg.button == arg.button.left DO
(
print "draggin started on Button 2"
storeText = theButton2.text
sourceButton = 2
local dragDropEffect = dotNetClass "System.Windows.Forms.DragDropEffects"
theButton2.doDragDrop theButton2.text dragDropEffect.Move
)
)

ON theButton3 mouseDown arg DO
(
IF arg.button == arg.button.left DO
(
print "draggin started on Button 3"
storeText = theButton3.text
sourceButton = 3
local dragDropEffect = dotNetClass "System.Windows.Forms.DragDropEffects"
theButton3.doDragDrop theButton3.text dragDropEffect.Move
)
)

ON theButton1 dragOver arg DO
(
local dragDropEffect = dotNetclass "System.Windows.Forms.DragDropEffects"
arg.effect = dragDropEffect.move
print "Dragging over button 1"
)

ON theButton2 dragOver arg DO
(
local dragDropEffect = dotNetclass "System.Windows.Forms.DragDropEffects"
arg.effect = dragDropEffect.move
print "Dragging over button 2"
)

ON theButton3 dragOver arg DO
(
local dragDropEffect = dotNetclass "System.Windows.Forms.DragDropEffects"
arg.effect = dragDropEffect.move
print "Dragging over button 3"
)

ON theButton1 DragDrop arg DO
(
theButton1.text = storeText
CASE sourceButton OF
(
2:
(
theButton2.text = ""
)
3:
(
theButton3.text = ""
)
)
print "Draggin ended"
)

ON theButton2 DragDrop arg DO
(
theButton2.text = storeText
CASE sourceButton OF
(
1:
(
theButton1.text = ""
)
3:
(
theButton3.text = ""
)
)
print "Draggin ended"
)

ON theButton3 DragDrop arg DO
(
theButton3.text = storeText
CASE sourceButton OF
(
1:
(
theButton1.text = ""
)
2:
(
theButton2.text = ""
)
)
print "Draggin ended"
)
)
createdialog testRoll 300 100
testroll.thebutton1.AllowDrop = true
testroll.thebutton2.AllowDrop = true
testroll.thebutton3.AllowDrop = true
testroll.thebutton1.text = "MOVE ME"
testroll.thebutton3.text = "MOVE ME TOO"
testroll.thebutton1.height = 20
testroll.thebutton2.height = 20
testroll.thebutton3.height = 20

Yes, the code is pretty crappy, and I'm not sure I'm using the drag and drop thing properly as I'm pretty sure that there's a more direct way than storing stuff in the local variables in the rollout. It works however.

So....what kind of beer have you got in the Netherlands?:beer:

ZeBoxx2
04-07-2009, 08:17 PM
uhhh.. Heineken? *runs*

You might want to pass the actual material rather than a variable name and the like? Though the effect is rather similar as the control's .tag property is used as an interim 'holder' for the value (a la .map for a mapbutton and .material for a materialbutton ).


rollout test "test" width:220 height:64 (
dotNetControl dno_drag "Windows.Forms.Button" text:"Drag" width:200 height:24
dotNetControl dno_drop "Windows.Forms.Button" text:"Drop" allowDrop:true width:200 height:24

on dno_drag mouseDown val arg do (
dno_drag.doDragDrop dno_drag.tag (dotNetClass "System.Windows.Forms.DragDropEffects").Copy
)

on dno_drop dragEnter sender args do (
args.Effect = (dotNetClass "System.Windows.Forms.DragDropEffects").Copy
)
on dno_drop dragDrop sender args do (
meditmaterials[2] = (args.data.getData "MXS_dotNet.DotNetMXSValue+DotNetMXSValue_proxy").value
)

on test open do (
dno_drag.tag = dotNetMXSValue meditmaterials[1]
)
)
createDialog test

MarcoBrunetta
04-07-2009, 08:47 PM
Well yhea, that looks a bit cleaner.
Would you care to elaborate on the " meditmaterials[2] = (args.data.getData "MXS_dotNet.DotNetMXSValue+DotNetMXSValue_proxy").value " line? Is that accesing the data that was stored when using the doDragAndDrop method?

Thanks for this btw, will surely make things easier.

Now if only there would be a "Material Preview" control I would be SO happy. Maybe for max 2011?

ZeBoxx2
04-07-2009, 08:55 PM
Would you care to elaborate on the " meditmaterials[2] = (args.data.getData "MXS_dotNet.DotNetMXSValue+DotNetMXSValue_proxy").value " line? Is that accesing the data that was stored when using the doDragAndDrop method?
Yep
args.data is a wrapper for the actual data being stored, which you then need to extract by format using getData and the format type (that big ol' string in the case of a dotnetmxsvalue). That gets you the dotnetmxsvalue.. which in turn is a wrapper for actual max data (the material), so gotta get that through .value.

wrappers within wrappers within event arguments within drag&drop events within abstracted dotnet objects within maxscript within max. whee!

Now if only there would be a "Material Preview" control I would be SO happy. Maybe for max 2011?
not in 2010, eh? ;\
Another script developer basically just created his own sphere and called 'render selected' on that.. seemed to work okay; it's more-or-less what medit does under the hood as well anyway.

MarcoBrunetta
04-07-2009, 09:15 PM
Another script developer basically just created his own sphere and called 'render selected' on that.. seemed to work okay; it's more-or-less what medit does under the hood as well anyway.

Yup, that's pretty much what I'm doing right now. But it's not pretty... and it can be messy. One of these days I'll learn some C and write a mxs extension. I think the Helium extension allowed that so it should be possible.

CGTalk Moderation
04-07-2009, 09:15 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.