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

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

Recommended Posts

Posted

I need to put some text formatting butttons (italic, bold, change color to red) above a text field so that the user can highlight some text then click the button to apply that format to the highlighted text.

The TextStyleAdd() and TextColor() functions look promising and also the Get(ActiveSelectionSize) and Get(ActiveSelectionStart).

I just don't know how to put them together (if these are indeed the right functions) to get the effect I need. Oh, and I am not talking about inserting HTML codes, but actually changing the look of the text on the screen as if the user had gone up to Format on the menu bar.

THANKS.

Posted

For bold, for example, make the button to 'Insert Calculated Result' of:

TextStyleAdd (

Middle ( Table::Textfield ; Get ( ActiveSelectionStart ) ; Get ( ActiveSelectionSize ) ) ;

Bold )

and so on. Make sure 'Select entire contents' is unchecked.

Posted

Thanks LaRetta and veteran for your great help.

I was able to use the script you specified, veteran, for the bold, italic, and underline buttons. To make the "red text" button, I replaced the TextStyleAdd function with TextColor. So far so good.

I just need to create one final button that says "plain" that will remove all styles AND color from the text. I know how to make the button do one or the other, but how do I combine the "TexStyleAdd Plain" and "TextColor RGB 0,0,0" calculations so that the text will be modified in both ways with one click of the button? Thx.

Posted

You nest the functions, so that one function operates on the result of the other one.

I wouldn't use TextStyleAdd ( text ; Plain ) though, since it does what it says - it actually tags the selected text with default plain style attributes. It's better to remove styling by using TextStyleRemove()B)

TextColor (

TextStyleRemove (

Middle ( Table::Textfield ; Get ( ActiveSelectionStart ) ; Get ( ActiveSelectionSize ) ) ;

AllStyles ) ;

0 )

Note that RGB ( 0 ; 0 ; 0 ) returns 0, so you can write that directly.

BTW, in all your buttons, the textfield name can be replaced by Get(ActiveFieldContents) - this will make the buttons operate on any active field, and you can copy them to other layouts/files without modification.

Posted

OK, great, I nested the functions and got the one calcuation to remove both style and color of the selected text (though for some reason TextStyleRemove Allstyles didn't work--had to use TextStyleAdd Plain).

Is there a way to keep the selected text selected after a format is applied (in case user wants to apply multiple formats to one piece of selected text)? Thx again, really great help.

Posted

TextStyleRemove() does work, but there is a quirk with Filemaker inserting the text at the selection point: there is a formatting tag there, and too often the plain text is inserted right AFTER the tag, which effectively returns you to where you started at. I don't have a good solution for this at the moment.

If you want to see what TextStyleAdd ( text ; Plain ) really does, make yourself a calculation field (result is text) =

GetAsCSS ( yourfield )

and observe the tags it inserts - when the desired result is to REMOVE the tags.

You can restore user's selection to the field - but not in a one-line button. You will need to use a script. Start the script by storing Get (ActiveSelectionStart) and Get (ActiveSelectionSize) - since you are in v.8, you can use variables for this. Do your formatting, then restore the selection by using the Set Selection [] script step.

This topic is 6958 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.