Possible bug with button (or more)

Started by Danetta, 07 December 2016, 17:49:50


I used a code which sends data to server.
The code executed when I press button.
I decided to disable button while user waiting for an answer from server to prevent packet-spamming.
When data arrives, button re-enabled.
However, if you keep your mouse cursor hovering the button while it's disabled, button graphically wont recognize a hovering from mouse after re-enabling even if you click on it. You need to move the mouse for any visible effect.
Button still will work when you click on it, you just wont see hover-difference.


This is not something that I could easily fix. When it is disabled it no longer receives events so it doesn't know if the mouse moved during that period or not. When it is enabled again it isn't allowed to check if the mouse is on top it or not because it might be possible that the mouse is on top of it while there is another widget in front of it. So the only way to fix this (without changing the fact that disabled widgets don't receive events) would be to send a signal to the root container every time you enable a widget to resend the last mouse event so that the widget could potentially update its state. That is a lot of work to to solve such a minor issue.

The issue may be bigger for you if you have no separate disabled image. If you use the themes that come with tgui then a disabled button looks identical to a normal button and you will thus see no difference when the button is re-enabled. If you would have a disabled image then it would change from disabled to normal instead of from disabled to hover which would be less problematic than seeing no visual change at all. So maybe you could add a "TextureDisabled" propery to the theme file that you are using.

Adding images for the disabled state in the Black theme is already on the todo list but I just don't have enough time to work on tgui right now and there are so many other things to do as well.


Thank you for fast and clear answer.
I will think about it and come back.