Detect Name of Button on Mouse Click

Keith Spieldenner kspieldenner at lifetouch.com
Mon Jun 3 11:01:26 EDT 2013


When I dynamically create objects, I typically set the behavior of the templateButton to point to a button on another card. That button contains the script for my new buttons.

So, on another card, create a button that contains something like this...

on mouseup
   switch the label of the target
      case "Say Hello"
         answer "You clicked on a button name" && the short name of the target & cr & the label of the target
	<do other stuff here>
         break
      default
         answer "You clicked on an unhandled button."
         break
   end switch
   pass mouseup
end mouseup

in the script that creates your buttons...

  set the behavior of the templateButton to "button id 1003 of card id 1002" --this is the reference to the button you created on the other card
   set the label of the templateButton to "Say Hello"
   create button "b_My New Button"	

Using this approach, you don't have to try and set the specific script of each button you create. You just manage the script in one place.

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
_____________________________________________________________________




More information about the use-livecode mailing list