Not working "when Switch.gotfocus"

Good day to all

I'm trying to track which Switch was switched before it was changed.
In the GotFocus event, I want to get the element number in the variable.
But gotfocus event doesn't work for Switch
LostFocus also does not work when switching to another element
Please help me figure this out.

The focus events are a leftover for previous old devices that used a trackball. As far as i know only the textbox retains its focus events.

You could try something like this to get the same/similar functionality

image

Thank you for your quick response. Maybe you know how to distinguish who changed the state of Switch.chenged user or program. I was thinking of using GotFocus for this.

You could set a variable when user or program sets the switch, so that you know which one changed the state

Thanks. That's what I'll do.

@TIMAI2 i want to follow your idea of setting up a variable, but how can i do that while i only have the .changed event? my switch can be changed automatically, but can also be triggered by a person when they click on it.. i wish there was something like a .clicked event.

The Changed() event can only be triggered by the user.
If an event occurred, the user clicked the switch.
This can be tracked in the global variable. (true/false)
About events in another element, change the states of all the others to false, and for the current element to true.

The above is not correct. Of course you can program the switch. In the below example i have used a button for demonstration purposes, but any other method, based upon some condition in the blocks can be used in the same way.

image

1 Like

Yes, that's right. I was wrong.
Make your own global variable for each switch.
Make sure that it is always "true":
When calling "Changed()" in the program, change the corresponding one to "false" before "Changed()" then again to "true".
And in the "Changed()" event, monitor its status.
If "true" - the user clicked "click", if "false" the call is programmatic.

You read my text but not my blocks....

thanks a lot.. it worked perfectly