Author Topic: How do you stop buttons from responding to right-click/middle-click?  (Read 12396 times)

Anomalous Underdog

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
I'm making a desktop game and all buttons seem to activate as well with middle-click and right-click.

I want to disable that, for all buttons (and all interactable widgets for that matter) in NGUI. I want it to respond only to left-click.

What's the best-practice way to do this?

Anomalous Underdog

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: How do you stop buttons from responding to right-click/middle-click?
« Reply #1 on: September 08, 2014, 05:40:11 PM »
Ok, I've been taking a look at the UICamera script. Seems like it's hardcoded to use all three mouse buttons (it loops through Input.GetMouseButtonDown(i) from 0 to 2), and they're all considered the same as far as NGUI is concerned.

I'll just end up editing the code here. If anyone knows of any less intrusive way to selectively choose if NGUI as a whole responds to left/middle/right click, let me know.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How do you stop buttons from responding to right-click/middle-click?
« Reply #2 on: September 08, 2014, 10:49:13 PM »
They are not the same. If you want a button to only respond to right-click, check for UICamera.currentTouchID.
  1. void OnClick ()
  2. {
  3.     if (UICamera.currentTouchID == -1) Debug.Log("Left click");
  4.     else if (UICamera.currentTouchID == -2) Debug.Log("Right click");
  5. }

Anomalous Underdog

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: How do you stop buttons from responding to right-click/middle-click?
« Reply #3 on: September 09, 2014, 02:49:02 AM »
Ok, thanks for that. I wanted a way to do it without having to check for the touch ID on each and every of the buttons/scrollbars I make. I added 3 booleans to UICamera on whether to process or ignore left/right/middle click inputs.