Focused/Unfocused events not working properly in 0.8.7

Started by densm27, 31 July 2020, 12:00:08

densm27

Hello texus & everyone.

I found what seems to be a regression in tgui.net in 0.8.7+ versions.
So, I take the example code from https://tgui.net/example-code/, and add focused/unfocused event handlers to the widgets:

editBoxUsername.Focused+= (sender, eventArgs) => Console.WriteLine("uname focused");
editBoxUsername.Unfocused+= (sender, eventArgs) => Console.WriteLine("uname unfocused");
editBoxPassword.Focused+= (sender, eventArgs) => Console.WriteLine("pass focused");
editBoxPassword.Unfocused+= (sender, eventArgs) => Console.WriteLine("pass unfocused");


After launching the app and clicking any of the widgets once, i get both focused and unfocused messages for the same widget immediately. Second click at the same element, or click outside of it does not trigger any events. Click on the other widget works the same as the first one, triggering both events for it simultaneously.

Downgrading to 0.8.6 nuget package fixes the issue, but unfortunately is not an option because of the checkbox/radiobutton creation bug present in that version.

texus

I have patched the issue. There was a typo that caused the Unfocused handler to be connected to Focused callbacks instead of Unfocused callbacks.

There isn't a new nuget package yet, but you can download the up-to-date nightly build by clicking the following download link: TGUI.Net-0.8-dev-64bit.zip