BobWeaver Posted January 20, 2002 Posted January 20, 2002 A few people have posted questions to FMforums about how to use multiple buttons to trigger a single script and then have that script take different actions according to which button was clicked. Currently, there is no Status(CurrentButtonName) function to determine which button triggered the script, but here is another possibility. You can use the following concept to create a dynamic vertical tool bar on your layouts. It's based on the idea of putting buttons in a portal. It's simple. Create a related file with a key field, a button name field and/or a button icon field, other parameter fields, etc. Create a relationship in your main file to the dynamic button file based on MainFile::KeyField = ButtonFile::KeyField. Then, create a portal on the layout in the main file. Insert the button name/icon field from the related file. Create an invisible button over the portal row. Link the portal button to a script that begins by setting a global field to the key field in the related file. Then the script can perform various actions based on the parameters stored in the dynamic button file. The key field in the main file can either be a regular text field or a global. The field will have multiple items (one for each button to be displayed) separated by returns, like this: NewRecord
danjacoby Posted January 20, 2002 Posted January 20, 2002 Or you could duplicate your script, making adjustments for each button, and linking them. I like simple solutions, I do.
BobWeaver Posted January 21, 2002 Author Posted January 21, 2002 Depends on what you are trying to do. This method lets you separate your data from your code to a certain extent.
Steven H. Blackwell Posted January 21, 2002 Posted January 21, 2002 You can also insert a StatusCurrent Modifier Key test onto the button and have it branch according to what modifier key is held down when it is clicked. Old Advance Man
BobWeaver Posted July 12, 2002 Author Posted July 12, 2002 The link to the example file may no longer be current. One of the following should work: try this or this
SteveB Posted July 12, 2002 Posted July 12, 2002 I frequently have to deal with this issue. Bob's method seems to be more complicated than necessary and won't work if there are no records in the file. Checking which key is being held down is unavailable in a Kiosk (I think), and requires either a message on a layout or very well trained users. I think the easiest way is with a bunch of 2 line scripts: SetField(_CurrentButton#, "Button 1") Perform Script("My Script) SetField(_CurrentButton#, "Button 2") Perform Script("My Script") _CurrentButton# is a global text. For consistency, I always assign the button the actual name of the button.
Recommended Posts
This topic is 8238 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