Page 1 of 1

get button name

Posted: Wed Sep 29, 2010 10:44 pm
by appsurd
Hi Guys!

I have the following script. However, I need to get the name of the button that was pressed to initiate this event. The value of "boxDay" should be the button name. Is this possible, if so how?

Code: Select all

on mouseUp
   put the short system date into unfDate
   set the itemDel to "/"
   put the item 1 of unfDate into tDay
   put the item 2 of unfDate into tMonth
   if tMonth is not 12 then
      answer "Sorry, you can't open any boxes until December."
   end if
   if tDay < boxDay then
       answer "Sorry, you can't open boxes for days in the future."
   end if
end mouseUp
Thanks.

Re: get button name

Posted: Wed Sep 29, 2010 11:14 pm
by bn
Hi appsurd,
assuming you want to get the name of the button "boxDay" you just clicked which has the mouseUp handler you describe you could say

Code: Select all

put the short name of me into myVariable
However I would be reluctant to name a button "1/12/2010" or somesuch, Livecode might attempt to do a calculation on that. Names should start with a letter or underscore. You could name the button "Dec1" which is safe and set the label of the button to "1/12/2010". Labels are OK to contain anything. Than you would script

Code: Select all

put the label of me into myVariable
The label is what shows up on the button as, well, the label. If no label is set the name appears instead. You set the label in the property inspector -> Basic properties. So I guess from what you describe that could work for you.
regards
Bernd