Author Topic: Bug in UIButtonColor when dragging  (Read 5887 times)

TypoStraw

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 19
    • View Profile
Bug in UIButtonColor when dragging
« on: July 29, 2014, 08:18:23 AM »
I have a couple of buttons set up with a UIButton and UIButtonColor that will invert colors when pressed (http://i.imgur.com/bPZbD2F.png)

If I press and hold on one of the buttons, and move the mouse over a different button, the new button label will change color to the pressed state and thereby hide the label (white text on white background).

Here's a video of it in action: http://gfycat.com/InstructiveSandyDragonfly

If I instead of UIButtonColor use UIButton, it works just fine, since it has some extra checks in the OnDragOver method (line 225):

  1. if (isEnabled && (dragHighlight || UICamera.currentTouch.pressed == gameObject))

At line 245 of UIButtonColor it doesn't check for this - it only checks for isEnabled.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Bug in UIButtonColor when dragging
« Reply #1 on: July 30, 2014, 09:42:20 AM »
Will changing the 'if' statement to this in OnDragOver/OnDragOut resolve your issue?
  1. if (isEnabled && UICamera.currentTouch.pressed == gameObject)

TypoStraw

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Bug in UIButtonColor when dragging
« Reply #2 on: July 30, 2014, 09:45:22 AM »
Yeap, however, it won't be a good fix for everybody since the dragHighlight variable in UIButton won't be usable.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Bug in UIButtonColor when dragging
« Reply #3 on: July 30, 2014, 10:57:59 AM »
dragHighlight is an option for the button, so not sure why this would matter in your case? To be honest, there is little reason to use UIButtonColor at all, and it even prompts you to update it to UIButton when you try to use it. UIButtonColor is only kept for backwards compatibility purposes.

TypoStraw

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Bug in UIButtonColor when dragging
« Reply #4 on: July 30, 2014, 11:09:53 AM »
Ah kay, just figured I'd use UIButtonColor in this case since I only needed the color change and not the rest of the UIButton functionality.

The dragHighlight variable doesn't matter for me, I was just thinking about it generally. The reason I state that it won't fix it for everybody is because of line 225 of UIButton.
  1. if (isEnabled && (dragHighlight || UICamera.currentTouch.pressed == gameObject))
  2.         base.OnDragOver();
If dragHighlight is true but the pressed object isn't gameObject, it would still activate the base.OnDragOver, but since I copied the gameObject check the method will just stop there - dragHighlight would have no effect.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Bug in UIButtonColor when dragging
« Reply #5 on: July 30, 2014, 11:17:17 AM »
True. Well, stick to UIButton in any case.