Author Topic: UIInput drag  (Read 7323 times)

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
UIInput drag
« on: October 15, 2012, 05:44:29 AM »
Hi !

I've done a form with some UIInput and a draggable panel for iOS.
But every time I start to drag the panel (touching a UIInput), when I release my finder the keyboard shows up...

Is there a way to disable the UIInput when the user drag ?

Thanks !

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput drag
« Reply #1 on: October 15, 2012, 05:51:09 AM »
In OnDrag() disable UIInput. In OnPress(false) enable it.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: UIInput drag
« Reply #2 on: October 15, 2012, 07:38:36 AM »
Thanks. I've been doing this :

  1. void OnDrag()
  2. {
  3.         enabled = false;
  4. }
  5.        
  6. void OnPress(bool isPressed)
  7. {
  8.         if (!isPressed)
  9.         {
  10.                 enabled = true;
  11.         }
  12. }
  13.  

But does not seem to be working

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput drag
« Reply #3 on: October 15, 2012, 12:09:28 PM »
You are enabling and disabling the script you have that code in, not UIInput.

Radazen

  • Guest
Re: UIInput drag
« Reply #4 on: October 15, 2012, 08:59:24 PM »
[I deleted my other thread on this topic for the sake of consolidating the issue here]

The OnDrag / OnPress approach isn't working for me. OnPress(false) fires before OnSelect(true) when the user releases a touch/mouse, so the UIInput is already enabled again by the time it receives the OnSelect, and it ends up popping up the keyboard as usual. Am I missing something?

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: UIInput drag
« Reply #5 on: October 16, 2012, 02:46:19 AM »
+1 here

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput drag
« Reply #6 on: October 16, 2012, 08:06:07 AM »
Alright, in that case keep it disabled, or better yet -- on another game object that doesn't have a collider.

When you want to start typing, select it yourself manually via UIInput.selected = true.

Radazen

  • Guest
Re: UIInput drag
« Reply #7 on: October 16, 2012, 11:38:52 AM »
Keeping the UIInput disabled doesn't seem to work for me, and enabling/disabling it during callbacks gives weird results because the order of SendMessage receivers doesn't appear to be consistent.

Using a second game object without a collider works better, but it's still a bit quirky. Because there are two separate objects, UIInput.selected=true makes my UIInput the "selected" object, which means that clicking on the other object (the one that actually has a collider) will always trigger OnSelect(true) because that object never stays selected. The result: when the on-screen keyboard is already up, clicking on the collider will quickly pop the keyboard down and back up again instead of just ignoring the click and keeping the keyboard up like a normal UIInput would do.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput drag
« Reply #8 on: October 16, 2012, 11:50:53 AM »
Why would you be clicking outside when the keyboard is up?

Radazen

  • Guest
Re: UIInput drag
« Reply #9 on: October 16, 2012, 11:58:12 AM »
Me? I wouldn't be. My users? Because they're users, and they do silly things and touch everything they can touch.

I also have code that runs when the UIInput is deselected (validates the response, changes the colors of some things based on the input text, etc), and that stuff runs if the user presses the UIInput while the keyboard is already up, which isn't ideal.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput drag
« Reply #10 on: October 16, 2012, 01:10:10 PM »
Well, the keyboard hiding then showing itself when they click outside is not really a big issue, is it?

Point is, I can't really suggest anything else with how you can tweak it to work better without a lot more work.

Radazen

  • Guest
Re: UIInput drag
« Reply #11 on: October 16, 2012, 01:14:11 PM »
The keyboard stuff isn't a big deal, but I've been rejected by Amazon's Android Appstore for similarly trivial things before, and for the sake of Apple/Google featuring apps, I like to keep everything as polished as possible.

Anyway, I appreciate the effort...I'll probably just hack something into the actual NGUI code. Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput drag
« Reply #12 on: October 16, 2012, 01:20:27 PM »
Tell them to suck it and quietly resubmit. :)