sgrey Posted September 12, 2010 Posted September 12, 2010 Hello. I'm recently back to FileMaker and new to the forum, so thanks for any help. I'm trying to do something that I'm sure is fairly simple, but can not seem to wrap my aging brain around it. I want to toggle a the text in a field between two different type styles--plain and bold, for example. I can set button options for the field and use the TextStyleAdd function to change the text to bold, but I'm not sure how to change it back (without setting up a second TextStyleRemove button). I thought I'd use a simple If...Then calculation to change it. Essentially, one that did something like this: Step 1: If (the text is plain) Step 2: Then (change it to bold) Step 3: Else (change it to plain) I can't find a way to return the text style for step one. I thought that there might be something like the TextSize or TextColor functions for the style, but I'm not having much luck. Any ideas?
Vaughan Posted September 13, 2010 Posted September 13, 2010 I want to toggle a the text in a field between two different type styles--plain and bold, for example. I don't think you can toggle the styles. You'll need a "plain" button to un-bold the text that uses the TextStyleRemove() function. I don't think there is a function that returns the text's formatting, but I might be wrong.
comment Posted September 13, 2010 Posted September 13, 2010 I don't think there is a function that returns the text's formatting There are two: GetAsCSS() and GetAsSVG(). But it is not quite simple to use them for this.
Lee Smith Posted September 13, 2010 Posted September 13, 2010 Hi skyzer, and welcome to the Forum, Something like this? skyzer.fp7.zip
sgrey Posted September 13, 2010 Author Posted September 13, 2010 Thanks, all for the quick responses. To expand on my situation, I will have a list of words on a page. Ideally, the user would select each word they needed to by clicking on it, changing it from plain to bold. In response to Lee: This works great and is a very simple solution. (Actually, you gave a similar response to someone else a few years ago [color:blue]http://www.fmforums.com/forum/showtopic.php?tid/191035/ which I came across researching the topic before I posted. I probably should have realized that I could have adapted that one.) I can make the button clear and position it over the related field, so it looks like you are clicking right on the word. The one small drawback for me is that it requires three separate objects (two fields and a button) for each of the 100-200 different words I have, but it works. In response to comment: [color:green] "There are two: GetAsCSS() and GetAsSVG(). But it is not quite simple to use them for this. " I was able to get this to work by 1. Setting field2 to the GetAsCSS for field1 2. Using PatternCount to see if the word "bold" is in field2 3. Using an If...Else statement to set the style in field1 based on whether field2 had the word "bold" I had hoped to avoid a second field at all by creating a variable that held GetAsCSS(field1) and using PatternCount on the variable. Unfortunately, it looks like PatternCount only works on fields or text. Is a way to do this with only one field? In a related, but more general question, is it better to have more objects that are less complicated, or fewer, more complicated ones? For example, Lee's elegant solution uses three objects with a simple script and calculation. The solution inspired by comment has only two objects, but more involved scripts. In other words, will the final product run better one way or the other? Thanks again for your help. It's much appreciated.
comment Posted September 13, 2010 Posted September 13, 2010 I had hoped to avoid a second field at all by creating a variable that held GetAsCSS(field1) and using PatternCount on the variable. Unfortunately, it looks like PatternCount only works on fields or text. PatternCount() works only on text - but the text can be in a field as well as in a variable. It would be best if you clarified your overall purpose here; "a list of words on a page" doesn't say much, and marking something you may need later by making it bold is usually not a good idea.
sgrey Posted September 14, 2010 Author Posted September 14, 2010 PatternCount() works only on text - but the text can be in a field as well as in a variable. It would be best if you clarified your overall purpose here; "a list of words on a page" doesn't say much, and marking something you may need later by making it bold is usually not a good idea. You are correct, that is pretty vague. But, it is essentially accurate. It is a kind on inspection report where the user would indicate the condition of what they are looking at by using a checklist. There would be major categories, like "Left Rear Tire" which would be selected with a check box. The sub categories "low pressure" "high wear" "cupping", etc. would be listed across. The user would indicate the tire condition by selecting the word, changing its format. The client does not want to use more check boxes, radio buttons, or pull down lists. However, after thinking about what you said, it may be that an underline would work better. Rather than use the TextStyleAdd for the underline style, is there a way to use a script to add a bottom border to the field? I appreciate your thoughts.
comment Posted September 14, 2010 Posted September 14, 2010 What is the purpose of entering this data into a database? If you have any plans of getting the data out at some point, then you are on the wrong path. Text formatting is not data. It is very difficult to find records where "high wear" is bold, for example. Data should go into fields as values - and text formatting should merely reflect those values.
Vaughan Posted September 14, 2010 Posted September 14, 2010 However, after thinking about what you said, it may be that an underline would work better. Ok, that's funny. Moon Shadow, is that you?
sgrey Posted September 22, 2010 Author Posted September 22, 2010 What is the purpose of entering this data into a database? If you have any plans of getting the data out at some point, then you are on the wrong path. Text formatting is not data. It is very difficult to find records where "high wear" is bold, for example. Data should go into fields as values - and text formatting should merely reflect those values. (Sorry for the delay responding) You are right that designating text by changing the formatting would not make sense, if I would need to be searching for this data. I'm not really collecting this as data. This particular layout is fairly static and self contained and would simply be a printout. Being able to change the text formatting works for my purpose. This is only a part of a larger project. Strictly speaking, what I'm working on is not a typical database, but does take advantage of many of the capabilities of FileMaker, including some relational features and the ability to create a standalone solution. Again, thanks for your help.
sgrey Posted September 22, 2010 Author Posted September 22, 2010 Ok, that's funny. Moon Shadow, is that you? Nope, but I'm glad it made you smile. :
LaRetta Posted September 22, 2010 Posted September 22, 2010 The user would indicate the tire condition by selecting the word, changing its format. Moon Shadow, is that you? Actually you might not be far off. Here is a demo MoonShadow produced when vs. 7 first came out. It seems complex but is actually very simple. It shows ability to control (at Admin level) which fields can be formatted different colors, bold etc and by how much). Some fields SHOULD allow User formatting at times. If you want to use checkboxes of words this won't work but, as you said, if you want to select a word and allow User to make changes, this will work. Style Assistant IIRC, vs. 7 suffered from a few text formatting anomalies (the field would hold the color improperly) so the process could be simplified now. And, with today's functions and capabilities in vs. 11, it could be simplified even further. But I believe that the concept (allow Users SOME formatting control on only SOME fields) is a good one. And it can be attached easily to any file as it stands without need of manipulation.
sgrey Posted September 23, 2010 Author Posted September 23, 2010 Thanks. It's nice to know that I'm on the cutting edge of something 6 years old. :
Recommended Posts
This topic is 5234 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