Overriding modal default behaviour (was: Re: Changing Label Text on Substacks)
Eric Chatonet
eric.chatonet at sosmartsoftware.com
Fri Dec 9 04:30:00 EST 2005
Hi Trevor,
Clever trick that overrides modal default behaviour.
Can be very useful.
Think that Dan should add it to his best-of list :-)
Thanks.
Best Regards from Paris,
Eric Chatonet
Le 9 déc. 05 à 00:12, Trevor DeVore a écrit :
> The secret to having a modal dialog that you can update is this:
>
> go invisible stack "MyModal" as modal
> set visible of me to true
>
> By opening the stack as invisible your scripts won't halt but you
> will display a modal dialog.
>
> Here is a script I use in a progress dialog. It goes in the stack
> script. The scripts use a bunch of setProp/getProp handlers to
> show/hide/update the dialog. The script expects that you have a
> scrollbar named "Progress" and a field named "Feedback" on the
> stack. Here is an example of how I use it:
>
> set the uTitle of stack "MyProgress" to "Updating Database"
> set the uFeedback of stack "MyProgress" to "I'm updating stuff.
> Keep your pants on."
> set the uProgress of stack "MyProgress" to 0
>
> --> Do stuff to update progress
> set the uProgress of stack "MyProgress" to currentAction/totalActions
>
> =====
> == START SCRIPT
> ====
>
> local sEndValue = 100
> local sCenterOnScreen = "true"
>
>
> setProp uTitle pValue
> set title of me to pValue
> end uTitle
>
>
> setProp uFeedback pValue
> set htmlText of fld "Feedback" of me to pValue
> wait 50 milliseconds
> end uFeedback
>
>
> setProp uCenter pValue
> if pValue <> false then put true into pValue
> put pValue into sCenterOnScreen
> end uCenter
>
>
> setProp uProgress pValue
> if pValue is not a number then put 0 into pValue
> put round(pValue) into pValue
>
> if pValue >= 0 then
> if visible of sb "Progress" of me = false then show sb "Progress"
> of me
>
> set thumbPosition of sb "Progress" of me to max(0, min(pValue,
> sEndValue))
> else
> hide sb "Progress"
> end if
> end uProgress
>
>
> setProp uEndValue pValue
> if pValue is not a number then put 100 into pValue
> put round(pValue) into sEndValue
> set the endValue of sb "Progress" of me to max(0, sEndValue)
> end uEndValue
>
>
> getProp uProgress
> return thumbPosition of sb "Progress" of me
> end uProgress
>
>
> setProp uShow pValue
> local tTarget = ""
>
> if pValue = true then
> put line 1 of openStacks() into tTarget
> if sCenterOnScreen = false AND tTarget <> empty then
> put loc of stack tTarget into tLoc
> else
> put screenLoc() into tLoc
> end if
> go invisible stack (short name of me) as modal
> set loc of me to tLoc
> set visible of me to true
>
> --> GIVE IT TIME TO DISPLAY
> wait 100 milliseconds
> else
> put true into sCenterOnScreen
> set the uEndValue of me to 100
> --put 100 into sEndValue
> close me
> wait 0 milliseconds
> end if
> end uShow
>
>
> setProp uComplete pValue
> set the uProgress of me to 100
> close me
> wait 50 milliseconds
> end uComplete
>
>
> getProp uShow
> if short name of me is among lines of openStacks() then
> return true
> else
> return false
> end if
> end uShow
>
>
> getProp uVisible
> if short name of me is among lines of openStacks() then
> return true
> else
> return false
> end if
> end uVisible
------------------------------------------------------------------------
----------------------
http://www.sosmartsoftware.com/ eric.chatonet at sosmartsoftware.com/
More information about the use-livecode
mailing list