AW: difference between closing with the red cross or sending close?
Hugh Senior
h at FlexibleLearning.com
Tue Oct 14 11:32:07 EDT 2008
Hi Tiemo,
'closeStackRequest' and 'closeStack' are messages, not commands. This means
you cannot send a 'closeStackRequest' any more than you can send a
'closeStack'. You can only 'close' a stack.
A stack will always get a 'closeStack' message, but if the user clicks the
red closebox the stack will also get a 'closeStackRequest' message first.
This means that when the user clicks the red closeBox, a closeStackRequest
message is sent followed by a closeStack message.
Lastly, you have to 'pass closeStackRequest' to continue with the close.
This is so you can optionally change your mind. This means you can stop a
closeStackRequest, but you cannot stop a closeStack.
To handle both a scripted close and a red-cross close, place your closing
routine into a shared handler and trap wheter the routine has already been
run (otherwise you will get it twice when the user clicks the red
closebox)...
on mouseUp
close this stack
end mouseUp
local isClosing
on closeStackRequest
answer "Are you sure?" with "Yes" or "No"
if it <> "yes" then exit closeStackRequest
put "true" into isClosing
doMyCloseStackStuff
pass closeStackRequest
end closeStackRequest
on closeStack
if isClosing <> "true" then doMyCloseStackStuff
end closeStack
on doMyCloseStackStuff
[../..]
end doMyCloseStackStuff
I have scripted the above so you can see what happens. Personally, I would
put the trap in the doMyCloseStuff handler thus...
on doMyCloseStackStuff
if isClosing = "TRUE" then exit doMyCloseStuff
else put "TRUE" into isClosing
[../..]
end doMyCloseStackStuff
Hope this helps.
/H
Hello again,
sometimes the basics are the hardest :) I want to be able to close my stack
by the standard "red cross" AND also by one of my self made menu items
"Close".
Using "on closeStackRequest" traps the standard closing by the cross and
after answering "yes" the stack closes. BUT sending "closeStackRequest" from
my menu and answering "yes", nothing happens. But always when picking a
second time the close menu and answering "yes" the stack closes.
Using "close myStack" in my menu didn't worked as expected either (as posted
before)
So what is the straight forward way to close from the title bar and a self
made menu with an answer trap?
Thank you
Tiemo
More information about the use-livecode
mailing list