ScriptSpot

Forum topic · General Scripting

I want to change the messageBox behaviour in my script

By Haider of Sweden · 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 of Sweden · 2014-03-06

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

barigazy · 2014-03-05

But if you looking better solution then try this

.

Haider of Sweden · 2014-03-05

@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?

barigazy · 2014-03-05

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

.

Haider of Sweden · 2014-03-05

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?

barigazy · 2014-03-05

Try with this

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

.

Haider of Sweden · 2014-03-05

Almost done.
It needs to destroy the previous popup too :)

barigazy · 2014-03-05

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

-- next cahnge this
global msgRollPopup,msgRoll

barigazy · 2014-03-05

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

.

Haider of Sweden · 2014-03-06

@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 · 2014-03-05

Replace it with regular rollout.

barigazy · 2014-03-05


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()
)
)