forcing a font

I have a text field whose font preference is set to Arial, input method
is set to "synchronize with field's font." If someone types in the
field the text is Arial. If someone drags text into the field it becomes
Arial. But if someone pastes text into the field it retains its original
font, which is bad for complicated reasons. Is there any way to force
pasted text to change to the field's preferred font?
Bill Steele [ Mo, 02 Juli 2007 20:00 ] [ ID #1757404 ]

Re: forcing a font

On 2007-07-02 13:00:56 -0500, Bill Steele <ws21 [at] cornell.edu> said:

> I have a text field whose font preference is set to Arial, input method
> is set to "synchronize with field's font." If someone types in the
> field the text is Arial. If someone drags text into the field it becomes
> Arial. But if someone pastes text into the field it retains its original
> font, which is bad for complicated reasons. Is there any way to force
> pasted text to change to the field's preferred font?

What version are you using?
Sean Walsh [ Mo, 02 Juli 2007 21:11 ] [ ID #1757406 ]

Re: forcing a font

In article <2007070214114416807-walshsr [at] yahoocom>,
Sean Walsh <walshsr [at] yahoo.com> wrote:

> On 2007-07-02 13:00:56 -0500, Bill Steele <ws21 [at] cornell.edu> said:
>
> > I have a text field whose font preference is set to Arial, input method
> > is set to "synchronize with field's font." If someone types in the
> > field the text is Arial. If someone drags text into the field it becomes
> > Arial. But if someone pastes text into the field it retains its original
> > font, which is bad for complicated reasons. Is there any way to force
> > pasted text to change to the field's preferred font?
>
> What version are you using?

8.0
Bill Steele [ Do, 05 Juli 2007 21:12 ] [ ID #1760365 ]

Re: forcing a font

On 2 Jul., 20:00, Bill Steele <w... [at] cornell.edu> wrote:
> I have a text field whose font preference is set to Arial, input method
> is set to "synchronize with field's font." If someone types in the
> field the text is Arial. If someone drags text into the field it becomes
> Arial. But if someone pastes text into the field it retains its original
> font, which is bad for complicated reasons. Is there any way to force
> pasted text to change to the field's preferred font?

There is a way to force a phone number into a certain format, e.g. ###-
####-####.
I believe the same technique can be used here.

Add an auto-enter calculation to your input field. Set the calculation
to something like this:

If(Length(input_field) >0 ; TextStyleRemove(input_field;
AllStyles); input_field)

You should also uncheck the box "Do not replace existing value of
field (if any)".

Ths should do the trick.

If you want to make really nice, you can make it into a custom
function with a number of variables, in order to better control which
styles and formats you want to zap and which to preserve. Check out
the various text formatting possibilities in the help menu.

Remember to share your custom function with the rest of us at
briandunning.com - maybe there's already a CF for you there.
Biberkopf [ Mo, 09 Juli 2007 21:50 ] [ ID #1763408 ]

Re: forcing a font

On 2 Jul., 20:00, Bill Steele <w... [at] cornell.edu> wrote:
>
> I have a text field whose font preference is set to Arial, input method
> is set to "synchronize with field's font." If someone types in the
> field the text is Arial. If someone drags text into the field it becomes
> Arial. But if someone pastes text into the field it retains its original
> font, which is bad for complicated reasons. Is there any way to force
> pasted text to change to the field's preferred font?

Another way to add to the other suggestions, is to have a second
version of the field which is a Calculation field set to simply "copy"
the field the users can paste into.
ie.
c_DataField Calculation (Text Result), Unstored
= UserField

The c_DataField is the one you use for printouts, etc. Unlike the Copy
command, the Calculation only takes the data, not the formatting.


With some Layout trickery you can also make it so that users only see
the "fixed" version.

Put both fields on the Layout, with the UserField hidden beneath the
c_DataField, making sure to turn OFF the "Allow user entry" Field
Format option for the c_DataField. Also remove c_DataField from the
Layout's Tab order. That way when users click on or Tab to the "single"
field they are taken to the UserField, but otherwise only see the
correctly formatted c_DataField.

The only real problem is that when users do click / Tab into the field
they will see the original incorrectly formatted version, but there is
a way around that too. You will also need to do some extra work if the
Layout is also used to perform Finds.


With even further trickey you can set the c_DataField to act as a
button that runs a script. The script can copy the contents from the
correctly formatted c_DataField back into the User field when it is
clicked on before letting the user see it.
eg.
Set Field [UserField, c_DataField]
Go To Field [UserField]

Similar to using a Calculation, the Set Field command only takes the
actual data, not the formatting (unlike using the Copy and Paste script
commands, which do take the formatting).

The problem is that you can't run a script when the user Tabs into the
field ... unless you have an extra plug-in.


If the Layout is being used to perform Finds, then you need to use the
"button" script technique, but modify the script to allow for Find mode
- when in Find mode simply go to the c_DataField instead of the
UserField. (You don't need to worry about Preview mode or Layout mode
since buttons don't function in either of those modes - make sure the
script is not listed in the Scripts menu so users can't run it by
accident.)
eg.
If [Get(CurrentMode) = 0]
# 0 means we're in Browse mode
Set Field [UserField, c_DataField]
Go To Field [UserField]
Else
# otherwise we're in Find mode
Go To Field [c_DataField]
End If

Note: the # symbol is the Comment script command and those two lines
can be left out.

You will have to turn the "Allow user entry" option back on for the
c_DataField, but since it's now defined as a button it doesn't matter
because the user can't click into it (it should still be left out of
the Tab order).

The only problem here is the Tab order when in Find mode. Unfortunately
there's no work-around that can be done to fix that (an extra plug-in
might again help here, but I'm not sure if any of them work in Find
mode).


Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)
Helpful Harry [ Di, 10 Juli 2007 06:08 ] [ ID #1764409 ]

Re: forcing a font

In article
<1184010630.087566.159890 [at] d55g2000hsg.googlegroups.com>biberkopf
<jespersoholm [at] gmail.com> wrote:

> On 2 Jul., 20:00, Bill Steele <w... [at] cornell.edu> wrote:
>> I have a text field whose font preference is set to Arial, input
>> method is set to "synchronize with field's font." If someone types
>> in the field the text is Arial. If someone drags text into the field
>> it becomes Arial. But if someone pastes text into the field it
>> retains its original font, which is bad for complicated reasons. Is
>> there any way to force pasted text to change to the field's
>> preferred font?

> There is a way to force a phone number into a certain format, e.g.
> ###-####-####.
> I believe the same technique can be used here.
>
> Add an auto-enter calculation to your input field. Set the
> calculationto something like this:
>
> If(Length(input_field) >0 ;
> TextStyleRemove(input_field;AllStyles); input_field)
>
> You should also uncheck the box "Do not replace existing value
> offield (if any)".
>
> Ths should do the trick.
>
> If you want to make really nice, you can make it into a custom
> function with a number of variables, in order to better control which
> styles and formats you want to zap and which to preserve. Check
> outthe various text formatting possibilities in the help menu.
>
> Remember to share your custom function with the rest of us
> atbriandunning.com - maybe there's already a CF for you there.
>

There is a rather elegant CF there, TextStyleRemoveAll ( Fieldname ):

Evaluate ( Quote ( FieldName ) )

Matt
Matt Wills [ Di, 10 Juli 2007 15:30 ] [ ID #1764419 ]

Re: forcing a font

In article <1184010630.087566.159890 [at] d55g2000hsg.googlegroups.com>,
biberkopf <jespersoholm [at] gmail.com> wrote:

> Add an auto-enter calculation to your input field. Set the calculation
> to something like this:
>
> If(Length(input_field) >0 ; TextStyleRemove(input_field;
> AllStyles); input_field)

Would that also remove any internal formatting, e.g., bold and italic?
Bill Steele [ Di, 10 Juli 2007 22:35 ] [ ID #1764429 ]

Re: forcing a font

In article <ws21-457636.16350110072007 [at] newsstand.cit.cornell.edu>,
Bill Steele <ws21 [at] cornell.edu> wrote:

> In article <1184010630.087566.159890 [at] d55g2000hsg.googlegroups.com>,
> biberkopf <jespersoholm [at] gmail.com> wrote:
>
> > Add an auto-enter calculation to your input field. Set the calculation
> > to something like this:
> >
> > If(Length(input_field) >0 ; TextStyleRemove(input_field;
> > AllStyles); input_field)
>
> Would that also remove any internal formatting, e.g., bold and italic?

And, trying it, it does. It doesn't change the font, but wipes out any
text styles. This works, however:

If(Length(body text) >0 ; TextFontRemove (body text))

It works when the user clicks out of the field. I'd prefer it to be
instantaneous, but this is a definite improvement.
Bill Steele [ Di, 10 Juli 2007 23:14 ] [ ID #1764432 ]
Datenbanken » comp.databases.filemaker » forcing a font

Vorheriges Thema: Image box
Nächstes Thema: relational drop-down menu (like in a portal)