Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

change button appearance when clicking it

Featured Replies

I have a set of 7 buttons - one for each day with an attached script.

 

If I click a button, I want its background to change color.

 

This works, but only when pressing it. It then goes back imediatly to previous appearance.

 

I want it to keep the new background color to help remember the user what he choose.

 

When he clicks any of the 6 other buttons, that button will then be the one with the new background color.

 

Do you need a script to do that?

 

What you are describing is Button State, which only works for one button.

 

Are you using Tabs, or trying to navigate between Table Occurrences?

 

Perhaps you can speed up this process by attaching a copy of your file.

See if this helps you.

 

Note the use of script parameters and just one script (not “scripts”), plus a global $$variable, Conditional Formatting and the Refresh Object step (new in FM 13).

SevenButtons_eos.fmp12.zip

Hi eos,

 

I was going to make a demo also, but wanted to understand better how these buttons were going to be implemented.

 

I noted that you grouped the buttons, and I’m not sure that the OP will know that they will need to ungroup them in order to drill down to see how these work.

 

Lee

Hi eos,

I noted that you grouped the buttons, and I’m not sure that the OP will know that they will need to ungroup them in order to drill down to see how these work.

 

Hi Lee, 

 

I wanted to make my life easier with the "Refresh Object" step.

 

OTOH, one could refresh the button corresponding to the old $$, and then the one for the new $$ … The best code is probably not only the one you never wrote (no bugs!), but also the one that comes to you 5 min. after you submitted the “final” version …  :ermm:

:yep:

Why not just add the refresh?

TheScript
Set Variable [ $sp; Value:Get ( ScriptParameter ) ]
Set Variable [ $$buttonNumber; Value:$sp ]
Refresh Object [ Object Name: "buttonRow" ]
Set Variable [ $dayOfWeek; Value:Mod ( $sp ; 7 ) + 1 ]
#
#here would be what you original scripts are doing, now simply using the script parameter, so you only need one (1) script Show Custom Dialog [ Title: "You clicked button no. " & $sp; Message: List (
"Weekday is " & GetValue ( List ( "Monday" ; "Tuesday" ; "Wednesday" ; "Thursday" ; "Friday" ; "Saturday" ; "Sunday" ) ;
$sp ) ;
"Internal day of week is " & $dayOfWeek ;
); Default Button: “Gee”, Commit: “No” ]
Refresh Window
[ Flush cached join results; Flush cached external data ]
  • Author

To EOS:

 

I adapted your script and it works fine.

 

However, I cannot click anywhere on the layout until the window it generates is closed.

 

How could the user navigate at will on the page and then close that Windows when is ready to?

sedekk –

 

just delete the “Show Custom Dialog” line; instead, you could add the steps from your original script(s) – using the script parameter passed from the button instead of hard-coded values. The variable assignments are just to show how you can convert a parameter to another value, should that be necessary.

  • Author

Thank you,

 

I will try that solution.   This was very helpful.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.