Scripting a button to ask for content in a textbutton, I find it hard to avoid execution of the further lines of the script, if user shall be able to escape.
The original script goes:
on mouseUp
ask"Give a short name to a new textbutton"
put it into knapnavn
clone button "prototext" of stack "Mindmapping"
set the visible of it to true
set the name of it to knapnavn
set the width of btn knapnavn to the formattedWidth of btn knapnavn
set the height of btn knapnavn to the formattedheight of btn knapnavn
set the loc of it to 997,14
set the textfont of it to "Arial"
end mouseUp
But if user regrets and clicks cancel, the cloning takes place and delivers a nameless button- So i need an if clause before the cloning . But failed to find the way to script it. Neither the info on ask or info on cancel in the LC library gives me a clue.
Hope for help
Kresten Bjerg
if cancel end mouseup ?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 253
- Joined: Wed Aug 19, 2015 4:29 pm
Re: if cancel end mouseup ?
Code: Select all
on mouseUp
ask"Give a short name to a new textbutton"
if it is empty then
exit mouseup
else
put it into knapnavn
clone button "prototext" of stack "Mindmapping"
set the visible of it to true
set the name of it to knapnavn
set the width of btn knapnavn to the formattedWidth of btn knapnavn
set the height of btn knapnavn to the formattedheight of btn knapnavn
set the loc of it to 997,14
set the textfont of it to "Arial"
end if
end mouseUp
Re: if cancel end mouseup ?
So simple !
Thank you very much !
Maybe a note about this should be added to the "ask" and the "cancel" in the LC library
Thank you very much !
Maybe a note about this should be added to the "ask" and the "cancel" in the LC library
Re: if cancel end mouseup ?
Well: From the dictionary about "ask file..."
...
If the user cancels the dialog, the it variable is set to empty, and the result function returns cancel.
...

...
If the user cancels the dialog, the it variable is set to empty, and the result function returns cancel.
...

Re: if cancel end mouseup ?
The ASK specification could helpfully include the following lines
:
"If the ask-script involves further operations, these are not cancelled. To escape from this trap, user has to include
if it is empty then
exit mouseup
else"

"If the ask-script involves further operations, these are not cancelled. To escape from this trap, user has to include
if it is empty then
exit mouseup
else"