About Store Forum Documentation Contact



Post Reply 
Possible bug in Button
Author Message
fatcoder Offline
Member

Post: #1
Possible bug in Button
If you hold the left mouse button down on a button and then disable that button, the button becomes locked in the on state. Any calls to try to turn the button off fail.

For example, open the Buttons gui tutorial and then add the following code to the update method.

Code:
if(Kb.bp(KB_A)) button_a.disabled(true);
if(Kb.bp(KB_S)) button_a.set(false, true);

Now when you run the tutorial, hold the left mouse button down on button a. While the left mouse button is down, press the "a" key on your keyboard. Now release the left mouse button.

You will notice that the button now stays in the on state. Shouldn't it release to the off state when disabled, if not set to BUTTON_STAY mode?

Finally, press the "s" key on your keyboard to try and force the button back to the off state while it is disabled. You will see that this has no effect and the button stays on.

This bug (or feature) is causing a lot of trouble for me in my gui. All my attempts to work around it so far have failed. I've tried overriding almost everything in an attempt to turn the button off when it gets disabled.
03-26-2013 02:28 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Possible bug in Button
Hello,

When setting disabled for gui object, it's not processed at all (update not processed).
Once you set disabled to false, it starts processing and it will get unpushed on its own.
Button.set as in comments is used only for BUTTON_STAY
At this moment I'm not considering changing state of Button upon the call of 'disabled' method.
03-26-2013 03:16 PM
Find all posts by this user Quote this message in a reply
cmontiel Offline
Member

Post: #3
RE: Possible bug in Button
As advice you can override update method, and make your desired behaviour in there.

Code:
STRUCT(CustomButtonClass, Button)

        virtual void update(C GuiPC &gpc);
};

IRC: irc.freenode.net
Channel: #Esenthel
03-26-2013 05:23 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #4
RE: Possible bug in Button
Quote:When setting disabled for gui object, it's not processed at all (update not processed).
I figured that was the case after hours trying to solve this problem. It seems once a button is disabled it no longer responds to anything at all.

Quote:Once you set disabled to false, it starts processing and it will get unpushed on its own.
This would require disabled to be set to false, then run a frame to update, then set disabled back to true. The problem with this is that you have a frame where the button is enabled, which causes bad things.

Quote:As advice you can override update method, and make your desired behaviour in there.
Already tried that. The problem is that once disabled the button stops responding to anything you tell it to do. So unless I write my own button from scratch, I guess I'm stuck.

All I need to do is set "_on" to false. Unfortunately, like many members in all the gui controls, it is set to private and cannot be accessed. Why are all the gui control members set to private? Makes it very hard to override their behaviour. If these members were set to protected, it would solve so many problems, with so many controls. I would be able to throw away so much band aid code.
03-27-2013 01:26 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Possible bug in Button
Are you calling disabled for the button or its parents?
Could you provide a video of your project so I could see the reasoning of setting disabled? And how does it look like overall?
03-30-2013 11:01 AM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #6
RE: Possible bug in Button
I'm calling disabled() on the actual button.

Not really sure what a video (or even screen shot) can show, but here is one anyone from the Buttons tutorial.

   

You can see the button on the left is enabled, the one in the middle is disabled (looks the same) and the one of the end was disabled, while it was on (the mouse button was held down on the button when disabled was called). You can see this button is now stuck in some strange disabled/on state that is very confusing. Any calls to the button are ignored and any calls to see if the button is on returns true, when it should be false. How can a button be on when it is disabled?
04-01-2013 10:19 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: Possible bug in Button
Next release will have the necessary changes.
04-07-2013 11:19 AM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #8
RE: Possible bug in Button
Thank you very much.
04-07-2013 03:35 PM
Find all posts by this user Quote this message in a reply
Post Reply