Notifications
Clear all

[Closed] Problem with Button Property

Hi guys!!!

I need some help…lets see if anyone knows why this is happening.

I took a code from internet to get a pop-up window and it works perfectly, but now am making a rollout window with more buttons and option and now it doesnt works…and i cant figure out why.

This is the code:

on Export_Animation_Btn pressed do
	(
		struct myCoolDialogs
		(
			labelStr,
	
			stringQuery = rollout stringQuery "String Query"
			(
				local returnStr
				
				label lblHeader
				editText etInput
	
				fn launch label: =
				(
					destroyDialog Export_Animation_Btn.myCoolDialogs.stringQuery
					if label != unsupplied then
					Export_Animation_Btn.myCoolDialogs.labelStr = label
					else Export_Animation_Btn.myCoolDialogs.labelStr = "Enter some text:"
					createDialog Export_Animation_Btn.myCoolDialogs.stringQuery modal:true
					returnStr -- only put it here if the dialog is modal
				)
	
				on stringQuery open do
				(
					Export_Animation_Btn.lblHeader.text = Export_Animation_Btn.myCoolDialogs.labelStr
					setFocus etInput
				)
	
				on etInput entered str do
				(
					destroyDialog Export_Animation_Btn.myCoolDialogs.stringQuery
					returnStr = str
				)
			)
		)
	
		Export_Animation_Btn.myCoolDialogs = Export_Animation_Btn.myCoolDialogs() -- as there are variables, an instance is needed
		result = Export_Animation_Btn.myCoolDialogs.stringQuery.launch label:"Animation name:"

)

When I execute this it works, the rollout appears, but when I hit the button a warning message gets out.

– Unkonown property: “myCoolDialogs* in ButtonControl:Export_Animation_Btn

Does anyone knows wich one the problem is?

Thanks!!!

9 Replies
 lo1

The fact that you’re declaring a struct inside the local scope of an event handler of a button does not make that struct a property of that button. Why would you expect it to?

Coz am a 3D modeller and my programming knowledge its too low… xD

Do you know how I could fix it?

 lo1

Either move the struct outside the button handler or the struct instanciation code inside it.

Sorry for bothering u but i can achieve it…

I have move the “Struct” outside the “on Export_Animation_Btn pressed do” but how can i now call that Struct from outside the button to inside? :S

Thanks a lot!

 lo1

I don’t know how the rest of your code is structured. Can you post a simple structure that shows what you’re trying to do?

This is a button that helps me to export and object animation saving it in the correct folder, even been a single mesh or a group, and the struct is to pop up a windows where asks me the name of the animation


on Export_Animation_Btn pressed do
	(
		
                --there beggings the pop up window

                struct myCoolDialogs
		(
			labelStr,
	
			stringQuery = rollout stringQuery "String Query"
			(
				local returnStr
				
				label lblHeader
				editText etInput
	
				fn launch label: =
				(
					destroyDialog Export_Animation_Btn.myCoolDialogs.stringQuery
					if label != unsupplied then
					Export_Animation_Btn.myCoolDialogs.labelStr = label
					else Export_Animation_Btn.myCoolDialogs.labelStr = "Enter some text:"
					createDialog Export_Animation_Btn.myCoolDialogs.stringQuery modal:true
					returnStr -- only put it here if the dialog is modal
				)
	
				on stringQuery open do
				(
					Export_Animation_Btn.lblHeader.text = Export_Animation_Btn.myCoolDialogs.labelStr
					setFocus etInput
				)
	
				on etInput entered str do
				(
					destroyDialog Export_Animation_Btn.myCoolDialogs.stringQuery
					returnStr = str
				)
			)
		)
	
		Export_Animation_Btn.myCoolDialogs = Export_Animation_Btn.myCoolDialogs() -- as there are variables, an instance is needed
		result = Export_Animation_Btn.myCoolDialogs.stringQuery.launch label:"Animation name:"
	
		--there watches if is group or single mesh
                
                gru = ""
		FOR obj in selection WHERE isGroupHead obj DO gru = obj.name
	
		single = false
		if gru == "" then
		(
			single = true
			gru = $.name
		) 
		gru
		
		if single == false then
		(
			for obj in $ do 
			( 
				if obj.baseObject as string == "Dummy" then
				(
					move obj [-obj.pos.x,-obj.pos.y,-obj.pos.z]
				)
			)
		)
		else
		(
			move $ [-$.pos.x,-$.pos.y,-$.pos.z]
		)
	
	
		--folder setup

                sitio = "D:\\Game\\assets\\res\\objects\\low\\obj\\"
	
		--folder setup + name of the selected object

                makedir (sitio + gru) all:true
	
		
	        --exports the animation with the name from the pop up window

		exportfile (sitio+gru+"\\"+gru+"_"+result+".gr2") selectedOnly:true using:Granny_Exporter
		
		max undo

This is a button that helps me to export and object animation saving it in the correct folder, even been a single mesh or a group, and the struct is to pop up a windows where asks me the name of the animation

Thanks a lot!

 lo1

Wow, I have no idea what any of that is supposed to do.

Also, you might want to use CODE tags in your CGTalk posts, and to properly indent your code so other will be able to read it.

Doesn’t this do what you want?

on Export_Animation_Btn pressed do
(	
	rollout stringQuery "String Query"
	(
		editTExt etInput "whatever"
		
		on stringQuery open do
		(
			setFocus etInput
		)
			on etInput entered str do
		(
			returnStr = str
			destroyDialog stringQuery
		)
	)
	createDialog stringQuery modal:on

	print stringQuery.etInput.text
)

Thanks for your replay and for your advice, I didnt knew the

 thing.

Am away from work now so i'll check it out tomorrow.

Thanks!!!

It works perfectly!!!

Thabk you soooo much for your help!!!

I owe u one hehe