How to know what field is clicked on when it's treated like a button

I have a number of fields that I want to change when I click on them, is there some way that Filemaker can be aware of what field is clicked on other than naming them?

So I have Table::Field1 and Table::Field2

Right now I have a script on Field1 which says "Perform my script and pass in Table::Field1" and then the same script on Field2, but I let it know it's Field2.

I tried "get(ActiveField)" and it doesn't grab the field name/path since it's not selected.

Is there some way around this I'm missing? the only two ways I've figured out to do it are pass in the script parameter, or to manually "name" each field it's path...

if your field are browse mode check (and editable, didn't tried on calc ones), you can put a script trigger OnObjectEnter on them and pass to the script get(actifivefieldname).

this has caveats, one of it is that he can be slow if field content is big

But I would go with script parameter.

What's your goal ? is it just to save a lot of mousing declaring the parameters on each button ?

if so, you could create one field, put the buttton on it with its param. Then you duplicate you field / buttons to the necessary nuber. Then you select all your field/buttons, and you copy that , then with something like clip manager, you get the xml code of your buttons, and you edit your code in and ide, and then paste bac thourgh clip manager.

But not sure you'll gain much time

1 Like

OK thanks. Partially to save time clicking, but also make it more bulletproof if I need to change a field name or table name or something down the road.

The other reason is I have the same action on multiple screens, using different joins. So on one screen it might be Students:DCF and on another it might be Tasks:Students:DCF. I want to just copy the field with all it's formatting intact and have it "just work", so as the layout gets tweaked I don't have to manually update all of them.

using Vincent's

OnObjectEnter on them and pass to the script get(actifivefieldname)

is the simplest way to dynamically get the field name, as for the table name, use the script step Get ( LayoutTableName )

Piecing together this and a previous post of yours I have attached a sample of what I believe you are trying to accomplish.

Adding a new field is down to two steps;

ON THE LAYOUT

  1. clone field
  2. change the placeholder text

onObjectEnter-fieldToggle.zip (85.1 KB)

@Vincent_L @rivet Thank you! Super helpful. Very elegant.