Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: MegaX on April 08, 2014, 07:19:57 PM
-
So I've been working on a chat feature for my game. The chat box background is hidden normally. It shows up when you hit Enter and then you're allowed to type in something to send. The desired effect is when you click somewhere outside of the box, the background becomes hidden again.
I binded Enter to select the input field and show the background, easy. But I'm having trouble hiding the background correctly. Using the scroll bar as well as clicking inside the chat box shouldn't hide the background. I've tried a bunch of different stuff, nothing really worked. How should I approach this?
The first image is the normal one, input field and background hidden, can't chat.
The second image is after you hit Enter, background shows up, you can type in the input field.
-
Whenever you click on something, that "something" gains the selection, and whatever was selected before loses the selection. This means that the latter receives OnSelect(false), and the former then receives OnSelect(true). Since you are typing in an input field, the input field is what has focus. The input field will get OnSelect(false) when it loses focus -- so just have a script listen for that.
-
Yes, I understand that. The problem is that if I click on the scroll bar and scroll the text, that sends a OnSelect(false) to the input field as well. But in that case, I don't want to do anything.