eyedoctor Posted August 18, 2017 Posted August 18, 2017 Hi guys Hoping for some intellectual input from those more experienced than I. I am trying to create a "portable tick box" By this I mean a script that I can attach to any field to make it a tick box So far I have created a number field and set it to display all non zero values as a tick. I have then attached a scriptrigger which runs a script on entering the field The script is as follows: Set Field by Name [Get (ActiveFieldTableName)& ::" & get (ActiveFieldName);Abs (Get (ActiveFieldName)& "::" & get (ActiveFieldName)-1)] This way if the field is empty it will be set to 1 and if it isn't it will be set to zero. So far, when I click into the field it correctly sets it to 1 and displays the tick but it remains at 1 and won't zero which I don't understand. Can anyone see the flaw? Joseph
comment Posted August 18, 2017 Posted August 18, 2017 Get (ActiveFieldName) gets the field's name. You want to modify the field's value, so set the field to = Abs ( Get ( ActiveFieldContents ) - 1 ) or simply = not Get ( ActiveFieldContents )
eyedoctor Posted August 20, 2017 Author Posted August 20, 2017 Awesome. This works really well. I notice though that by using this method, that the 1 or 0 becomes momentarily visible before seeing the tick If I set the field directly ( set field rather than set fieldbyname) that the 1 or zero is not displayed
comment Posted August 20, 2017 Posted August 20, 2017 2 minutes ago, eyedoctor said: I notice though that by using this method, that the 1 or 0 becomes momentarily visible before seeing the tick That is the nature of the hack you have devised: a script triggered OnObjectEnter runs after entering the field - and while a field is active it will display its contents unformatted. If you use a button instead, the field won't be entered at all and you won't see the raw contents. What is the purpose of these boxes?
eyedoctor Posted August 20, 2017 Author Posted August 20, 2017 They are just tick boxes. Look better than the native Filemaker ones. Problem with attaching a script, is that the field is not entered and so the Get(active fieldname) won't work because the field is never active
comment Posted August 20, 2017 Posted August 20, 2017 1 hour ago, eyedoctor said: Problem with attaching a script, is that the field is not entered and so the Get(active fieldname) won't work because the field is never active That is correct: you need to use a script parameter to identify the field. Or attach a single-step action to each button.
eyedoctor Posted August 20, 2017 Author Posted August 20, 2017 I like the idea of the single step action, but how would this work?
comment Posted August 20, 2017 Posted August 20, 2017 You would have to define each button individually, with the specific field being hard-coded in the Set Field[] script step.
eyedoctor Posted August 20, 2017 Author Posted August 20, 2017 I think that in the end, this is probably a better and simpler approach. Thank you for your advice Joseph
Recommended Posts
This topic is 2920 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now