Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Dynamic Dialog Issue when dialog is modal

Dynamic Dialog Issue when dialog is modal

keithm
Enthusiast Enthusiast
690 Views
2 Replies
Message 1 of 3

Dynamic Dialog Issue when dialog is modal

keithm
Enthusiast
Enthusiast

Has anyone else experienced this and know a work around?
Is there a way to simulate Modal for 3ds dialogs?

The situation occurs when you dynamically create a rollout and add it to a SubRollout UI element within a rollout that is displayed in a dialog, via createDialog and that has modal set to true.  The dynamically create UI is non-responsive.  This was not the case in Max 2018.  

(
	global RenderElementsOptions
	
	try( destroyDialog testModal ) catch()
	
	rollout testModal ""
	(
		label lb01 "test dynamic rollout in modal"
		subrollout REO_subrollout "Render Elements Controls" pos:[10,30] width:410 height:240
		on testModal open do
		(
			local ControlNumber = 1
			local RendElement = Z_Depth()
			local AddProp = "zMin"
			local exStr = "" as stringStream
			local tnValue = 3
			
			format "rollout RenderElementsOptions \"% Controls\"\n(\n" ( classof RendElement ) to:exStr
			format " label LB_% \"%\" offset:[60,0]  align:#left across:2  \n" (ControlNumber as string) ((AddProp as String) )  tnValue to:exStr
			format " spinner spn_% \"\" width:60 type:#integer range:[0,65535,%] align:#center\n"  (ControlNumber as string) tnValue to:exStr
			format " on spn_% changed val do\n(\nREtest.% = val\n)\n" (ControlNumber as string)  (AddProp as String) to:exStr
			format "\n)\n" to:exStr
			format "%\n" exStr
			
			execute ( exStr as String )
			
			AddSubRollout testModal.REO_subrollout RenderElementsOptions
			
			setFocus testModal.REO_subrollout
		)
	)
	createDialog testModal 430 400 modal:true
)

Code above will generate a dialog with a dynamic subrollout.  Changing the modal:true to false will allow the interface to work, but the dialog will no longer be modal. (not desirable in my situation)

Thanks
Keith R Morrison

Max 2021

0 Likes
691 Views
2 Replies
Replies (2)
Message 2 of 3

denisT.MaxDoctor
Advisor
Advisor

It works for me with 3DS MAX 2020. To be honest, I can't understand why this might not work for versions later than 2020. Because they have to use the same UI libraries and mechanics.

0 Likes
Message 3 of 3

Serejah
Advocate
Advocate

I asked exactly the same thing in discord channel and here's Swordslayer's answer.


@Swordslayer написал (-а):

Modal stuff is tricky and hacky since it's not a property of the window but making all the other windows of the app disabled. For example, if you replace your primary rollout with this snippet, you can re-enable the inserted rollout by pressing a button like this:
    rollout primary_rollout "primary" width:150 height:100
    (
        local ctypes = python.import "ctypes"
        button btn "Enable subrollout contents"
        subRollout sec width:140 height:80

        on primary_rollout open do
            AddSubRollout sec secondary_rollout

        on btn pressed do ctypes.windll.user32.EnableWindow (UIAccessor.GetFirstChildWindow sec.hWnd[1]) on
    )
 
 
An ugly workaround to enable the window automatically (as it gets disabled after the rollout open handler finishes) would be to use timer:
rollout primary_rollout "primary" width:150 height:100
(
    local ctypes = python.import "ctypes"
    timer clock interval:50
    subRollout sec width:140 height:80

    on primary_rollout open do
    (        AddSubRollout sec secondary_rollout
        clock.active = on
    )

    on clock tick do (ctypes.windll.user32.EnableWindow (UIAccessor.GetFirstChildWindow sec.hWnd[1]) on; clock.active = off)
)

 

0 Likes