Yeah, that one suprised me a time or two also. Clicking a button doesn't give it the focus. To put the focus on a button, it has to be part of the tab order and then you can tab into the button much like you tab into a field. Tab into the button and then click it and your script will then correctly return the name of the button. (This is an object name assigned using the object info palette--not the button's label text.)
From a practical side, since you have to click the button to trigger the script, you can pass the button's name as a parameter to the script. (I can do that with Filemaker 10 and am pretty sure that filemaker 9 can as well.)
Pass in a script parameter when you specify the button in calling the script. Then you can use Get ( ScriptParameter ) to capture its value in the script.
Also I just looked at the help. The help states:
"When the focus is on the button,Get(ActiveLayoutObjectName) returns cancelButton"
This means when the button has focus on it such as when you can select it by tabbing to it. This has nothing to do with clicking the button.
Ok, thanks chaps.
Ill modify my storage location DB to suit. The original plan was to select a particular button to choose a location to store a job in, now ill tab to the location and create a single "store in selected location".
FYI I have just managed to work out how to get the button to report its own name and get it as a variable. The first script step needs to be Goto Object (name of the button just pressed) That makes it active. Then I have the second script step as run script (as above)
Since you have to name the button to go to it, wouldn't be simpler just to just use the name of the button as literal text?
It seems like your script is saying: go to button "xyz", Now let's see what's the name of the current button... oh yeah it's "xyz", use that text to....
Where it could just as easily skip the first part and you'll get the same results?
Mr. Vodka and I both suggested passing the button's object name as a parameter figuring you must be using the same script with different buttons.
I am having almost the exact same problem as dob85y: trying to use the object-name of a button in a script that runs when you press that button.
PhilModJunk, can you please clariffy when you say...
"Mr. Vodka and I both suggested passing the button's object name as a parameter figuring you must be using the same script with different buttons."
How can you set the object name as a parameter? I can only think of using Get (ActiveLAyoutObjectName) as a calulated parameter, but this raises the same problem of the button not being in focus on the layout when it is clicked.