We would like an easy way to set selected text in a field to a specific color. The user would select the text, invoke the script, and the text would turn color. How can we do that? (Going to the text color pallete each time gets tiring.)
benlevi, here is a sample of a script that should accomplish what you want.
Create a script and link it to a button. If you want more than one color, you could create multiple buttons or some other mechanism for the user to select a color and then pass the color selection to your one script that will then set the color.
In the script, suggest that you set some variables. Set these using the Get( ActiveFieldContents ), Get ( ActiveSelectionStart ) and Get ( ActiveSelectionSize ) functions.
Then use the Set Field script step, but you don't specify an actual field. That way it will work on whatever field the cursor is currently in.
In the calc of the Set Field, you need to use the Middle( ) function in conjunction with your variables to grab what is selected, then use the Replace ( ) function and the TextColor( ) functions to change the selected text color.
Finally, it is a nice touch to then re-select the text that the user had highlighted, so use the Set Selection[ ] script step with your variables to do this.
Let me know if you have trouble with this as I might have a sample file I can round up to illustrate this.
Thank you for the ideas... if you do have the script that does this, I would appreciate not having to spend the time reinventing the wheel; it's not straightforward, as I can't find any solution on the web.
When I go to Set Variables, it pulls up a window that has three fields: name, value, and repetition. So it doesn't look at all like the script you have laid out. Any help?
ignore the repetition box, it's not used here. Ignore the text "value:" this is added by the scripts workspace after you put in the info needed to set up the script step and close the dialog.
I'm sorry, but this leaves me without a clue what to put in the "name" box. The window posted above as "change color" doesn't look anything like the window I see when I go to the script workspace, add a new script, and select "Set Variable."
The text to the left of the ; goes in the name box. The text to the right of "Value:" goes into the second box.
The window posted above as "change color" doesn't look anything like the window I see when I go to the script workspace, add a new script, and select "Set Variable."
Bear in mind that the original post and solution was written 3 years ago... FileMaker's UI has changed somewhat since then. If you're using FM 15, double-click on Set Variable to move it into the script, or start typing SV or Set Variable to have FM 15 auto-enter the script step. Then click on the little gear icon to the right and you'll be presented with the actual dialog box that lets you enter the variable name and formula.
Retrieving data ...