Hi gyroscope,
why do you put this into an on mousedown handler? I rarely use this for buttons, the user can change his mind when pushing the button and release it outside the rect of the button, that way the mouseUp does not get triggerd. That is the usual interface convention.
What are you trying to do: what are the names of the buttons supposed to look like?
Wouldnt you rather prefer to set the
title of the button, that way you can still refer to the name in a script, it is a lot easier to maintain and debug then to change the name of the button.
If you want to your stack to be cross platform then the mac users rarely use the controlKey, it is the optionskey (alt) instead.
Lastly, you might want to catch the situation when a user clicks ok but has not put any text into the ask box, that returns empty and the name of your buttton will be set to empty.
Code: Select all
on mouseDown
if (not the controlkey is down) or (not the optionkey is down ) then
beep
else
ask "Change button title"
if the result is not "Cancel" and it is not "" then
set the name of me to it
-- set the title of me to it
end if
end if
end mouseDown
If you want to give the user two options plus the option to bail out (with cancel) then you could do this with
Code: Select all
on mouseUp
if (not the controlkey is down) or (not the optionkey is down ) then
beep
else
answer "Change button title" with "Cancel" or "red" or "blue"
if it is not "Cancel" then
set the title of me to it
end if
end if
end mouseUp
If you want to give the user more than two options then how about an option menu: the user understands this and no typos that your script can not control for. You can query this with
Code: Select all
put the label of btn "option menu" into myVar
if you dont want to go for the menupick of the option menu.
Then again you easily might have something special in mind that I dont know. Then forget about this all.
sorry for this lengthy post but I have the feeling it is easier to sort this out early in a project.
regards
Bernd