ScriptSpot home

Forum topic · General Scripting

I want to change the messageBox behaviour in my script

By Haider Alghifary · 2014-03-05

Description

Hello,

I have a script that looks like this:


macroScript AutoBackToggle
	category:"Haider"
	buttonText:"AB-Toggle"
	toolTip:"AutoBackup Toggle"
(
	on isChecked do (autoBackup.enabled)
	
	on execute do 
	if autoBackup.enabled == true then 
	(
		autoBackup.enabled = false 
		/*print (autoBackup.enabled)*/
		messageBox "Autobackup disabled." title:"Autobackup State" beep:false
	)
	else 
	(
		autoBackup.enabled = true
		/*print (autoBackup.enabled)*/
		messageBox "Autobackup enabled." title:"Autobackup State" beep:false
	)
)

The messageBox command will lock the user, forcing one to press OK before continuing.
How do I change the popup to be a regular information popup that doesn't "lock" the viewport?

Comments (12)
Haider Alghifary

.

I noticed some strange behaviours

- the rollout shows up upon Max startup, before I have pressed the button.
- rollout reappears even though I close it

Branko Živković

But if you looking better solution then try this

Reply to Branko Živković
Haider Alghifary

.

@But if you looking better solution then try this
I emailed you last time because I had some problems. It still doesnt work with me. Will look into it again and return to you with complete report on what happens.

Thanks for the fix
Could you please add so that if I dont close the popup, but press the button again, it kills the popup and recreats it, showing the right message?

Reply to Branko Živković
Haider Alghifary

.

It was you :)
I don't know what is the problem, really.

Hehe, yep :)
We'll check it later again.

Could you please add so that if I dont close the popup (red x), but press the toolbar-button again, it kills the old popup and recreats it, showing the right message?

Reply to Haider Alghifary
Branko Živković

Try with this

-- change this line
on isChecked do (msgRollPopup() ; autoBackup.enabled)

Reply to Haider Alghifary
Branko Živković

I wrote this on the phone. I can't test it

-- next cahnge this
global msgRollPopup,msgRoll

Reply to Branko Živković
Branko Živković

BTW you need to learn mxs very quick. Read mxs help document.
You have too meny questions :)

Reply to Branko Živković
Haider Alghifary

.

@BTW you need to learn mxs very quick. Read mxs help document.
You have too meny questions :)

You're so right. I am trying to catch up learning. Until then, I am at your mercy ;)
I made these changes to make it work:

global msgRollPopup,bgaRoll
..
..
try(destroyDialog ::bgaRoll)catch()
..
..
createDialog bgaRoll 150 26 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
miauu

.

Replace it with regular rollout.

Reply to miauu
Branko Živković


macroScript AutoBackToggle
category:"Haider"
buttonText:"AB-Toggle"
toolTip:"AutoBackup Toggle"
(
global msgRollPopup
fn msgRollPopup =
(
try(destroyDialog ::msgRoll)catch()
rollout bgaRoll "Autobackup State"
(
local msg = if autoBackup.enabled then " Autobackup enabled." else " Autobackup disabled."
label lbl msg pos:[5,5] style_sunkenedge:on width:140 height:16
)
createDialog bgaRoll 150 26 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
)
on isChecked do (autoBackup.enabled)

on execute do
if autoBackup.enabled == true then
(
autoBackup.enabled = off
msgRollPopup()
)
else
(
autoBackup.enabled = on
msgRollPopup()
)
)