Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 8162 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I need to know if there is a way to make something happen in a field when you click on it. I know that you can turn a field into a button but it has it's limitations. Here is an example of what I would like to do:

I have 50 fields and each has a toggle (x or blank). I would like the user to click the field and have it trigger a script (if x, then blank; if blank then x...).

The catch is, I only want to write the script once (as opposed to once for each field). It seems that there should be a way for FM to recognize which field to clear based on which field/button was clicked to trigger the script in the first place.

Any bright ideas?

Posted

Yes, you can tell what field you are in. The problem is when a field is clicked as a button, you are not yet in the field and you can't detect the field you "intend" to click into. To do what you wish really requires the ability to determine which field the cursor is over. It requires the ability to read and relate cursor position to field position. I've never seen a solution to this one.

-bd

(OBTW, we don't allow duplicate posts. I've deleted your post in the Plug-in Forum.)

Posted

If the only purpose of the script is to toggle the field between "x" and empty, consider changing the fields to number fields, then define a value list with one value - 1. Format your fields to use this value list, and resize so that only the checkbox shows. No button/scripting required.

Posted

I have a solution for you but it may involve reconsidering your overall app design.

Instead of having 50 different fields equal to X or O, you create a another file (call it fileXO) that has 50 records with one field (call it fieldXO) in each record equal to X or O. Then, in your master file, create a portal that displays fieldXO from all 50 records in fileXO (one in each portal row). Now make fieldXO activate a script that checks the value of fieldXO and toggles it accordingly.

I just tried this myself. It took about 10 minutes and it exhibits the behavior you've described. It may upset your current design but it is rather elegant in that it uses only one 5 line script and 1 field instead of 50.

Furthermore this solution can be tailored to accomodate ANY situation where you want multiple buttons activating one script that routes itself according to which button was clicked - something I've seen other developers asking for but usually walking away empty handed. I hope you can make use of this. Please let me know if you have any questions. I'll chekc back here later.

Posted

To continue from my previous reply (if I haven't confused you yet)B) This solution, as I've described it above, makes sense only if we're dealing with just ONE set of 50 toggle fields. Assuming that we are NOT (i.e. you need these 50 fields for multiple records) I have a simular but more advanced solution for that also. Its a little involved and perhaps not much more elegant than just having 50 seperate toggle scripts, but it will give you the desired behavior across multiple records without a bunch of little redundant scripts. Just give the word and I'll either describe it here or email it to you.

Posted

I have written a plugin which will get you the mouse position. If you know the positions of your buttons, you can figure out which button was clicked.

So, have every button run the same script. Get the mouse position as soon as the script runs (using the plugin) then compare x and y values with known button positions to determine which button was pressed. The rest is up to you.

The plugin is 'Jazz Utils', and is freeware. Go to http://www.jazzmedia.com.au/shareware.html.

Best of luck

John

This topic is 8162 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.