Toggle button or two-state toggle don't work on booleans?

Why would a two-state toggle button NOT be able to use a boolean? This is just irritating.
Why does Toggle Button not have a Control and Indicator binding? Again just irritating.
Seems like the most basic functionality and it has to be complicated and convoluted.

1 Like

Drag and drop your boolean tag onto a window - it’ll automatically let you choose a control to bind to, which includes the 2-state toggle and the ‘regular’ toggle button:



I keep getting this.

And there is this.


I dragged the bool onto the screen and chose 2-state toggle. Sorry, not trying to be a pain, but I just don’t get what is going on.
I have also tried this with a regular toggle button. I put it on the screen, then dragged this tag onto it.
image

That error looks like something’s bound to one of the appearance related properties - in default configuration, the different states of the 2-state toggle should be controlled by the ‘Style Customizer’ (right click the component -> Customizers -> Style Customizer).
Check whether the foreground or background color properties have the little warning triangle here, instead of the color swatch icon; that indicates there’s a separate binding on the style property, in addition to the style configuration:
image

This is just weird. I did a global search and made sure the tag is not used anywhere else in the project. I also checked in the PLC to make sure the tag is not being written to anywhere.
I deleted any object on this window tied to that tag (again), then dragged the bool tag directly onto the window. Chose 2-state toggle and did nothing else to it. Still getting the error of “can’t coerce false into type…”
I also tried the same thing with a standard Toggle Button, same result.
it tries to toggle the Control Value, but indicator does not change, and data quality briefly goes to 700.
I will probably just give up and build it myself, but I still wonder why.

Can you hit full on that error message and paste it in here? Might be a clue as to where it’s coming from in the stack trace.

I deleted the component, closed all windows and apps and rebooted the PC.
now it appears to be working correct. I also tried a standard Toggle Button.
sorry for the fire drill.

2 Likes

Maybe some can help me, 2-state toggle button have 2 tags to change value and change light. I don`t understand, when i switch on 2-state toggle button then this tag have true state, but when i click to this button again, “value” changed but indicator no, why? How i can fix it?

Bind the control value AND indicator value. Play with bi-directional setting

I use bi-directional setting. but that doesn`t work! And tag for indicator i use as like feedback for my tag value!

Can you post screen shots of your bindings and the style customizer settings?

I have many a similar button, and i want move it to templates. and they don`t work corectlly!


image


This is strange, I am testing it on 7.9.14 and seeing something similar.
I dropped a BOOL tag on a window, chose 2 State toggle.
Changed the Indicator binding to a second BOOL tag and now the button won’t toggle the first BOOL tag back to FALSE after toggling it to TRUE.

I had to put a script on BOOL 1 to write its current value to BOOL 2 on change in order for the button to work properly. It seems the Current State works off of Indicator value only and will prevent the second toggle.

@PGriffith is this the correct sequence for a 2 state toggle? Seems counter-intuitive to be not able to have a different indicator binding and not be able to toggle the control value.

If I use tag in current value similar to control value, all is working good! Thank you!!!

That’s by design. The idea behind having separate values you can bind to different tags is to ‘guarantee’ a process has happened via the PLC. The control value should indicate the attempt, from Ignition -> PLC, and the indicator value should indicate the result, from PLC -> Ignition. You absolutely can bind them to the same tag, or bind the indicator value directly to the control value, if you only have one tag.

So, unless I’m misunderstanding things, I would say that this is working as intended.

2 Likes

The issue is it doesn’t write to the BOOL control value tag after the first write if different tags are bound for control and indicator.
Steps to duplicate:
create 2 bool memory tags(BOOL1,BOO2)
Drag BOOL1 to window choose Control-2 State Toggle
Change the Indicator Binding on the button to BOOL2
Go to runtime and click the button a few times.

From every test I have done, it will do the initial write to the control value tag, but not toggle it after that.

im sorry, but i have glitch in my previous answer, and now it doesnt work again! control value changed value only in ignition not in PLC, i don`t understand why! Maybe you know?

@PGriffith bump, is this working as designed after my last reply?
Seems like a bug…

That’s still not a bug. You get one write, because the indicator value is saying “I haven’t been set” - so the one write attempts to update the control value (and succeeds). Then the indicator value never updates, so the component is ‘locked’ in a pending state.

If you choose to bind the indicator value and control value separately, there must be some external process synchronizing them back up.

See that seems counter intuitive to me.
The control value should toggle the control value no matter what the indicator value is.
If it was a button and not a TWO-STATE TOGGLE I could see the behavior you are describing.

The behind the scenes code should just be newValue = !currentControlValue

I see that it is working as designed, but it shouldn’t be called a toggle if its default action is not actually a toggle of the bound control value.