I have a question about using labels as buttons in Vision. A colleague of mine suggested that labels shouldn't be used as buttons due to them not acting the same as buttons. I have used this method on multiple different Ignition projects now and I have had no issues.
Does anyone know if this is the case? If so, I will need to change my "label buttons" to momentary buttons. I am reluctant to do so, as I can style labels much better to fit the look and theme of the application. Mainly, I can overlay a label on a rectangle and have the rectangle look like the button with rounded corners, etc.
It is just a mouse clicked event. The background of the rectangle is bound to an expression that changes the colour on hover. Other than that, they are fairly simple.
The major difference is that actual buttons have an actionPerformed event that honors enable/disable and security limits. Other events are uncontrolled. (Momentary buttons are another behavior entirely.)
They are suggesting that reading tags through a script on a label acts differently to a script on a button. I bind any tags to custom properties anyway then read their value from there, in read of using readBlocking/readAsync. In my mind there is no logical difference here when utilising the bound property in a script.
I have also seen some touchscreen drivers sometimes miss touch events in their default installation configuration but there are other events that were added to labels (not sure when) that seem to solve that problem. I think it was the pointer events that were working on touchscreens that would sometimes miss click events but I could be remembering wrong.
Buttons pick up some default styles that can be a little more awkward. It would be good if IA made a "label button" or maybe a better named control that is basically a label with all the things that a button has without all the default button styles. There's a lot of situations where I would want a hitbox on something but do not want to style the hitbox. My current solution for those situations is to use a button and style the opacity to 0 which feels like a kludge.
Labels-as-buttons are completely inaccessible to keyboard users. You can't tab into a label, press space to hit the button, tab out to the next control. If you're already doing all your scripting against the mouse everywhere else this is probably a moot point, but you're giving up functionality.
That's a great point. I like being able to use a mouse or a keyboard, and I often fret over things like tab order and enter key functionality when I do form design. I don't see a way to use a label button for that.
So, if you've been convinced that a transparent button overlay is the way to go, you may need to give some visible indication that it has the focus when arriving there via the tab key.
Just wanted to point out that it isn't impossible to achieve complex styling with a stock button, if you're willing to do a little scripting.
Not too difficult to also allow the background to change on hover. The example in the linked thread uses a transparent background because I couldn't be bothered at the time to write a renderer, but while not trivial is not unattainable either.