Author Topic: UIButton disabled state bug  (Read 7364 times)

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
UIButton disabled state bug
« on: March 13, 2014, 10:35:52 AM »
Hi ArenMook,

I think I have found a bug which appears when setting the UIButton.isEnabled = false;

I'm calling UIButton.isEnabled = false on a panel then the button is grey color (disabled color). But when I turn off the panel and turn the panel back on, the button is disabled but it has the normal color of the button.

How to reproduce:
Create button with a normal, hover and disabled color.
Disable the button at runtime
Turn the panel which holds the button off and back on.
The button now has the normal color instead of the disabled color

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton disabled state bug
« Reply #1 on: March 14, 2014, 12:27:12 PM »
I believe this was already addressed in 3.5.4, so give it a try after tonight's update.

Im_Lp

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UIButton disabled state bug
« Reply #2 on: May 26, 2014, 08:13:25 PM »
I hate to bring back a thread from the dead but the issue is still ocurring on the latest version of NGUI (3.6.0)

I am creating a navigation bar which highlights the currently selected "tab" by changing the enabled state of the sprites on the bar. It appears that whenever I toggle the state via UIButton.isEnabled or MyUIButtonObject.collider.enabled it doesn't trigger redraws. I went over it countless times thinking it was the FSM I wrote for the nav bar messing state changes but all navigation passed the unit tests I set in place.

As observed in different threads, hovering on/off the button does trigger the sprite changes.

Thoughts?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton disabled state bug
« Reply #3 on: May 26, 2014, 11:50:01 PM »
Did you ever change UIButton's defaultColor? Simply changing the sprite's color won't update the button.

Im_Lp

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UIButton disabled state bug
« Reply #4 on: May 27, 2014, 01:26:47 PM »
I did, but I do not believe that is the issue since it's not a color related issue but a sprite state issue.

This is how the background UIButton component looks right now for each of the buttons on my bar.


Now given 2 buttons A & B. Lets say Button A is currently on the "disabled" state. If I click Button B then A should be enabled and switch its sprite to the normal state, while button B should change to the "disabled" state. Like so:


Instead what occurs is that Button A stays using the "disabled" state sprite but responds to clicks while B shows disabled.



Head-scratching note: is that if I hover my mouse over the buttons, the sprites change to the correct states.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton disabled state bug
« Reply #5 on: May 28, 2014, 05:39:39 AM »
What you're doing doesn't make much sense to me. Why not us a toggle for this? You seem to be trying to mimic toggle functionality with the button script, which isn't what it was designed for. Look at the Tabs example that comes with NGUI.