get button name

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
appsurd
Posts: 10
Joined: Wed Sep 29, 2010 7:50 pm

get button name

Post by appsurd » Wed Sep 29, 2010 10:44 pm

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.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: get button name

Post by bn » Wed Sep 29, 2010 11:14 pm

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

Post Reply