Skip to content

Commit

Permalink
Merge pull request #5606 from vishalduggal/timob-11690
Browse files Browse the repository at this point in the history
[TIMOB-11690] TiAPI: hideKeyboard method for view
  • Loading branch information
srahim committed Apr 14, 2014
2 parents 95273ca + 94a0752 commit a8e07cb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.appcelerator.titanium.util.TiAnimationBuilder;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.util.TiUrl;
import org.appcelerator.titanium.util.TiUIHelper;
import org.appcelerator.titanium.view.TiAnimation;
import org.appcelerator.titanium.view.TiUIView;

Expand Down Expand Up @@ -82,6 +83,7 @@ public abstract class TiViewProxy extends KrollProxy implements Handler.Callback
private static final int MSG_FINISH_LAYOUT = MSG_FIRST_ID + 112;
private static final int MSG_UPDATE_LAYOUT = MSG_FIRST_ID + 113;
private static final int MSG_QUEUED_ANIMATE = MSG_FIRST_ID + 114;
private static final int MSG_HIDE_KEYBOARD = MSG_FIRST_ID + 115;

protected static final int MSG_LAST_ID = MSG_FIRST_ID + 999;

Expand Down Expand Up @@ -229,6 +231,10 @@ public boolean handleMessage(Message msg)
handleBlur();
return true;
}
case MSG_HIDE_KEYBOARD : {
handleHideKeyboard();
return true;
}
case MSG_FOCUS : {
handleFocus();
return true;
Expand Down Expand Up @@ -1128,4 +1134,25 @@ public boolean isLayoutStarted()
{
return layoutStarted.get();
}

@Kroll.method
public void hideKeyboard()
{
if (TiApplication.isUIThread()) {
handleHideKeyboard();
} else {
getMainHandler().sendEmptyMessage(MSG_HIDE_KEYBOARD);
}
}

protected void handleHideKeyboard()
{
TiUIView v = peekView();
if (v != null) {
View nv = v.getNativeView();
if (nv != null) {
TiUIHelper.showSoftKeyboard(nv, false);
}
}
}
}
7 changes: 7 additions & 0 deletions iphone/Classes/TiViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -2869,4 +2869,11 @@ + (TiViewProxy *)unarchiveFromTemplate:(id)viewTemplate_ inContext:(id<TiEvaluat
return nil;
}

-(void)hideKeyboard:(id)arg
{
ENSURE_UI_THREAD_1_ARG(arg);
if (view != nil)
[self.view endEditing:YES];
}

@end

0 comments on commit a8e07cb

Please sign in to comment.