I diabsle buttons all the time, based on values derived in a db at any given time (either real values in fields that I look at in a script or in gVars set by script runs that have occurred previous to the run of the current script).
If I want a button to be 'disabled' then I put an If/Then at the top of the script. The user clicks on the button and the script activates (every time, i.e., the button is always active, just the script -- based on what follows here -- might de-activate itself). If that initial If/Then proves 'true' (the data in the real fields or gVars is present), the next step is to Halt the script before it does anything (so the script never progresses past that inial If/Then. Sometimes I throw up a Cuustom Dialog informing the users that the script will not run. Your choice as to whether or not that kind of information is too intruisve for your users.
If the If/Then proves false (the data in the real fields or gVars is NOT present), then the If/Then is skipped and the script runs to completion.
Me too. But what I a after has two parts:
A visible clue to the user that the button won't work
Or hide it
But neither should act as a button, perform said script or show a black backgrounds as when the button is clicked.
Maybe it is no longer fashionable to grey out a disabled button on the part of the database engineers.
It would be a nice option to have.
My stage one attempt using a global set to another global or empty leaves the button clickable and produces a black square.
My next attempt is to use a tab and swith via script between tab one with the button and tab 2 no button.
Sometimes I 'cover' buttons up, but also add the If/Then to the button's script so that they work together. In the past I have used global container fields for this purpose, and calc out their needs, for example:
FieldA --> A field that holds a value (or NOT) that determines if your script will run or not (using the If/Then above);
Value --> The field point that determines if your script will run or not (this could also b a gVar within a script, or whatever, asd mentioned above); and
gCont1 --> A global container field you populate with some sort of graphic -- maybe just a block of white if the bg of your interface is white, etc. (set this when you have your db local as it won't 'stick' if you do this while the db is served).
Then, create a simple calc field to create the 'cover up' field needed, call it cCover (calculation, container):
If ( FieldA = Value ; gCont1 ; "" )
So, if Value equals the determining value, then the gCont1 block of white is set into cCover. Set cCoveron top of your button in your UI. When the FieldA data is not there, the button will show (and the associated script will run through past the initial If/Then); when the FieldA data is there, the button is covered up by the gCont1 graphic (and the script will Halt at the top).
You can then limit your If stmt in your script to:
If (not IsEmpty(gCont1)
That's it. Now, the button will continue to 'work' when gCont1 is populated with the white colored graphic -- that is, it will flash when its space in the UI is clicked, but since the script halts, nothing will actually happen. And because the cCover is the same color as your bg, the button won't even show up there in the UI.
Does that help at all?
If you are using simple graphics and text tools withing FMP to create your buttons and button text, you could do all of the above using Conditional formatting (to set button color and text color to white, for instance) basing your formatting changes on that same FieldA value. No need for all the fancy steps. I use a lot of custom built 3D buttons and shiat, so need the extra stuff provided by my cover up schema, but if your interface is simpler, Conditional Formatting might be the ticket.
All good sound ideas within the Filemaker world.
But, my original question was how to keep the button from highlighting if I click on it want it not to do anything. Empty Containers, buttons covered with opaque objects, all highlight regardless....
I can script a container to an image or to blank but I can't stop the button from highlighting regardless of my scripts. I even tried using a black background but then the highlight was white.
Now, there is one method to completely hide the button and I have just played with it a bit: sadly it doesn't work where I want to use it, in a list layout.
The technique is to use invisible tabs, or same color as your background. Put the button on the top layout and leave the second tab empty. Name the two tabs Tab 1 and Tab 2. Now, script go to object Tab 1 and the button is visible and can be clicked. Go to object Tab 2 and the button dissapears AND there is no button to click and cause the highlight. Works on Form layouts, not on Lists...
"But, my original question was how to keep the button from highlighting if I click on it want it not to do anything. Empty Containers, buttons covered with opaque objects, all highlight regardless...."
If you are using vs. 11 then you can use filtered portal. In this way, if the conditions you specify do not evaluate to Boolean true, the portal will be empty. Place one row portal just 2 px higher and wider than your button and center your button within it. It will work with form and list layouts (but not table).
It used to be known as the visibility trick and, depending upon your implementation, it can be quite easy to implement. I like it better than invisible tabs.
Right. Sorry I went off. Upon rereading your original, I see what you're on about more clearly. Thanks for pointing that out. Since it is a given the object that is the button will turn into that black square when clicked (it's been like that forever), I just went on with ways to mitigate that a bit. No need for any of that after all. LaRetta's suggestion for the invisibility is good.
LaRetta, that's close and probably perfect if I didn't hate making more TOs... At least it will work on a list where the tab doesn't.
Darn, I guess I have to make another TO... Imagine being able to push a value to a window by changing a global...
Let's see the table:
Graphics (container, 6 reps)
Code (text, 6 values for scripts to run)
=== to bad we can perform a script by name like we can go to layout...
OK, infinite records with 6 buttons each... Geesh, sounds like a main event loop from 20 years ago... :)
Oh, a global to control which record is displayed and be used in the analysis...
Life just got easier...
Now, a question: if a button highlights white on a black background and black on a white background, is there a grey background that equals its highlight? Or is the highlight only black or white? Guess I'll go answer my question.
I am not getting a white flash when I make the i/f black. But, I'm not sure that will matter to you.
I placed a black button on a black b/g and then turned off the hand cursor. The button works fine at all times (no change in color when clicked), but you can't see it (black against black). So, I placed another square of color behind the button (so that when clicked, the button will not toggle any color of the square behind (and outside) the button. Now, you see the button at all times, but it makes no color toggle when activated.
Not sure any of that helps, but wanted to let you know what my findings were. It's an intersting UI problem, for sure.
Oops, the idea is to have the button dissapear AND not flash when the button is clicked.
I did solve it using a global container that stores my buttons so I can just copy and paste the container and also change the button image if I want to.
When I don't want the button seen, I just fill the container with empty. But the button flashes.
UNTIL NOW! I found the shade of grey as a button background that doesn't flash when clicked if placed on a similar background color. Can I change the big green checkmark?
Now the graphics show when wanted and the button won't flash when clicked...but do I like the background? I'm sure there is a color somewhere that highlights as itself when clicked... Unknown how different monitors will handle this... Bet it fails...
"that's close and probably perfect if I didn't hate making more TOs.."
Create a table called buttons (or globals or whatever you wish; you can even use a Preferences table). All you need is one record. Set the relationship to Cartesian Product (the final 'x' in the relational connectors.
Put each button (or button group) in a different portal based upon this 'buttons' table (which is filtered by the various values you wish for THAT button or button group). You can control the filter directly from the portal or from a global in another table. If you use the filtered portal technique, the button won't flash because it won't be in the one-row portal at all unless the criteria is met for its display. You will still, however, need to remove displaying the hand cursor or it will still turn into a hand over the portal. But no flash to deal with.
What I meant by more TOs was that I would have to create one TO for each table I want to use this idea in and there may be 100s, well 15...
I understand most of the points you just made (20 years worth).
I did uncover the simple method of using a button background, the icon has transparent background, that matches a selected layout background or fill in a box. When clicked the button flash matches the layout color so it is basically invisible. Now I have to decide if I like that background color. Or if this idea can be used with a color. You've probably noticed how the color of the highlight changes with the color of the background, just find the color(s) where the flash is the same color of the background, invisible flash...
Here's my blog post showing the buttons. I've added a sample file to illustrate my concept. If you like the background color, it works. If you want another background color you will have to experiment with the container fill color...
I've done it with a combination of conditional formats, conditionals in scripts, and calculated fields for button text. Plus, if you want a button to disappear, you can't use a border because borders can't be conditionally formatted, so instead I fake a border with a second, conditionally formatted object behind the button and just slightly larger.
It is an absurd amount of work and mess for something that should be a basic feature. UI objects should be able to conditionally disable or disappear. Please FM, let's get this done!