Author Topic: Disabling hover states for mouse  (Read 4402 times)

admiral

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Disabling hover states for mouse
« on: March 09, 2015, 07:04:15 PM »
Hi,

I'm trying to make it so that "select" highlights on my buttons are only controlled by the keyboard and not mouse hover. I'm manually setting a sprite change on the UISprite on keyboard events, but moving the mouse over the button seems to "revert" the button to its default sprite. Am I missing something here?

Thanks!

admiral

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Disabling hover states for mouse
« Reply #1 on: March 09, 2015, 07:08:58 PM »
Ah, looks like I need to change the sprite on the UIButton using

uiButton.normalSprite = newSprite

instead of changing it on the UISprite component. My guess is that UIButton wants to control the sprite for hover states and things?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Disabling hover states for mouse
« Reply #2 on: March 10, 2015, 08:19:59 PM »
Yes, UIButton will override the normal sprite when you hover out. Generally you should stuck to one type of input -- keyboard/controller or mouse/touch, as otherwise it will be unclear what currently has focus/highlight.

ceng

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Disabling hover states for mouse
« Reply #3 on: April 17, 2015, 01:45:36 PM »
Generally you should stuck to one type of input -- keyboard/controller or mouse/touch, as otherwise it will be unclear what currently has focus/highlight.

Hi ArenMook,

This is unrelated to the original post but your recommendation caught my attention. I am currently developing a touch + controller enabled GUI am encountering the widget highlighting problems you alluded to. Switching from controller to touch generally works; there are two problems that occur when switching from touch to controller:

1. Switching from touch to controller does not seem to clear existing touches, which may lead to more than one widget being highlighted simultaneously. (In my case, this occurs when moving through a scroll view: the controller will scroll to show and highlight the next widget in the list, meanwhile that moves a different widget in the list beneath the stale touch, causing that widget to also become highlighted.)

2. Switching from touch to controller does not seem to track the most recently highlighted widget, sometimes preventing the controller from highlighting anything until another touch highlights something first.

I will investigate NGUI's source (version 3.6.1) to see whether I can solve #1 by clearing a touch list somewhere. I am unsure what I can do to solve #2 currently.

Thanks,
Chris



ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Disabling hover states for mouse
« Reply #4 on: April 18, 2015, 12:54:58 PM »
361 is quite old, you should upgrade first. In my post I mentioned sticking to one type of input. I didn't suggest switching from one to another. If you do switch, it's up to you to go through UIInput.activeTouches and/or UICamera.selectedObject and clear them.