Support => NGUI 3 Support => Topic started by: jindave on June 25, 2014, 05:25:35 AM
Title: UIInput on canceled event
Post by: jindave on June 25, 2014, 05:25:35 AM
Hello Tasharen team, I found that I often need to handle situation when mobile keyboard was canceled by user (He touched outside of keyboard). You reset the state like this:
Update function:
if(!mKeyboard.wasCanceled) Submit();
mKeyboard =null;
isSelected =false;
mCached ="";
I did small update which I guess can be handy for all:
Event declaration:
public List<EventDelegate> onCanceled =new List<EventDelegate>();
Update function:
if(!mKeyboard.wasCanceled) Submit();
else Canceled();
mKeyboard =null;
isSelected =false;
mCached ="";
Canceled function:
publicvoid Canceled()
{
if(NGUITools.GetActive(this))
{
if(current ==null)
{
current =this;
EventDelegate.Execute(onCanceled);
current =null;
}
}
}
Title: Re: UIInput on canceled event
Post by: ArenMook on June 25, 2014, 06:29:49 AM
You will get OnSelect(false) when you cancel it. Another advantage of OnSelect(false) is that it will work with more than just mobile keyboards -- stand-alone builds also send out OnSelect(false) when you click somewhere else.
Title: Re: UIInput on canceled event
Post by: jindave on June 25, 2014, 07:00:43 AM