Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

I would like to change the color of a rectangular object in my file with different buttons. How can I make this happen?   I would like to make a color change script . I don't know how to script that kind of change.

Posted

It's by conditional formatting, Rick. :-)

 

BTW, here is another option.  This one doesn't require any fields and only a single script.  Notice that the colour block has its object named to 'colour' ... this is what refreshes the layout using Refresh Object[] ...  new and powerful but not hoggish in 13.  Otherwise script parameter handles it just fine.

 

The block is simply a drawn button but you can use a text block as well - whatever can be used with conditional formatting.  

colors.fmp12.zip

  • Like 1
Posted

 new and powerful but not hoggish in 13.  

 

...But the OP has only FMP12.

Posted

Thanks for catching that, Doug!  Then a Refresh Window[] should do the job.  


On second thought ... use the old trick of using Freeze Window instead ... that should work fine and have less impact. :-)

Posted

Daniele, I think that the web viewer expression must be

"data:text/html,
<html>
<body margin='0' style=border:'0' bgcolor=#" & 
Table::Red 
 & 
Table::Green 
 &
Table::Blue  & "
>
</body>
</html>"

And the Red, Green, and Blue values must be in hex.  There is no rgb() function in html.

 

It should also be noted that LaRetta's solution using variables instead of a field will mean that the color will not be persistent upon closing and re-opening the solution, if that is important to Hartmut's solution.

 

Posted

 

There is no rgb() function in html.

 

If it had not existed, my example would not work.

See: http://www.w3schools.com/html/html_colors.asp where you could see that colors can be set by hex, rgb and name.

 

Other examples ( your and LaRetta's ) involve a fixed number of colors, but the one I proposed leave the user free to choose any persistent color.

Posted

Hi Doug,

 

We have not been given the purpose here so we all are guessing anyway.  However, if there were logic beneath the button clicks, which depend upon the underlying data and thus the colours should remain after the User closes, that can easily be incorporated into the solution.  Conditional formatting responds to any calculations such as:  If the button 1 is clicked, set a field to 'complete' ... then the conditional format would simply look to the complete field instead.  The functionality remains the same.

 

Nice example, Daniele!  It reminds me of a file by Comment from 2008 called colors_x11.fp7 where one can specify the colours.  I wanted to suggest it as an alternate as well but couldn't find the post.  In all, Hartmut now has options and that is what counts!

Posted

Well, this is awkward.

 

Hex (my revision)

post-75181-0-96147600-1409236193_thumb.j

 

rgb (Daniele's original)

post-75181-0-68929900-1409236213_thumb.j

 

OS is Mavericks; default web browser is Safari.  What is happening here?

Posted

It reminds me of a file by Comment from 2008 called colors_x11.fp7 where one can specify the colours.

 

It 's very likely that Comment has done a similar file, who among us has not done one? :laugh:

Posted

Absolutely true!  Over the years, we keep coming around to this functionality over and over!  It's always good to revisit things since our tools change/improve as well and the best tool for the specific job (and our memories) should always be re-evaluated afresh.  

Posted

My dilemma is solved.  rgb() is supported for the css background-color property, as Daniele rightly stated, but is not supported for the html bgcolor tag.  Changing his calc to 

"data:text/html,
<html>
<body margin='0' style="border:'0'; background-color:rgb(" & 
Table::Red 
& "," & 
Table::Green 
& "," &
Table::Blue  
& ")">
</body>
</html>"

made it display properly.

 

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