[Closed] materialBrowseDlg() question
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 [b][b]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 ?
[/b][/b]
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? 😮
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…
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
Ajaa! A challenge! You’r on mister.
This is what I’m toying with btw:
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.
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.
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
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?
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
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?