How to dismiss keyboard in flutter when I change the app using task list or if I pressed home button on iOS and double click home button and got back to app
You can reproducer the problem by doing the follow:
focus Textfield so keyboard will appear and double press home button on iPhone to switch to another app using task list then again double press home button and switch back to your app!
The keyboard stays and not responding
I tried the following :
#override
void didChangeAppLifecycleState(AppLifecycleState state) {
print('state = $state');
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
currentFocus.focusedChild!.unfocus();
}
SystemChannels.textInput.invokeMethod('TextInput.hide');
}
Related
How do I prevent clicking background when I click the IMGUI button
(e.g. I click the translate button and also click the background)
Check whether ImGui wants to capture the mouse click using ImGui::GetIO().WantCaptureMouse. If it does then don't let the event propagate further.
void Application::handleInput(InputEvent event) {
// don't pass mouse and keyboard presses further if an ImGui widget is active
auto& io = ImGui::GetIO();
if (io.WantCaptureMouse || io.WantCaptureKeyboard) {
return;
}
// ... event processing
}
}
ImGui FAQ: Q: How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?
I am implementing searchbar in Ionic 2. When I run the app in iOS, in simulator or on a real device it doesn't work properly. When I click Cancel the keyboard closes at first and then reopens again. The searchbar, still has the cursor in it.
This what I have done.
.html
<ion-searchbar
placeholder = "Kerko"
(keyup.enter)="search(q.value)"
[showCancelButton]="true"
(ionCancel)="reset($event)"
></ion-searchbar>
.ts
constructor(private navCtrl:NavController,
public keyboard: Keyboard,
private platform: Platform) {
}
search(q: string) {
console.log(q);
this.navCtrl.push(SearchPage, {"query": q});
}
reset(event) {
this.keyboard.close();
}
Any idea how to solve this?
I understand that with the new iOS 10, for Non-Force Touch devices, when the application is in the background, after swiping from right to left, you only see two options : View and Clear.
When I open the notification center however, and select the View option, I only see the alert, minus the action buttons beneath it. If I select view for other apps on my phone, I'm able to see the alert, along with the action buttons below it, if any.
The action buttons are visible when the app is in the foreground. Is there a setting that needs to be enabled in code?
Below is how I implemented the WillPresentNotification function.
public override void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action<UNNotificationPresentationOptions> completionHandler)
{
try
{
// Do something with the notification
Console.WriteLine("Active Notification: {0}", notification);
completionHandler(UNNotificationPresentationOptions.Alert|UNNotificationPresentationOptions.Sound);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + ex.StackTrace);
}
}
I am using notification.confirm in my iPhone application using phonegap.
$("#buttonId").click(function(e){
buyDialogBox();
});
function buyDialogBox(){
navigator.notification.confirm(
getIndRestrictionText(), // message
onConfirm, // callback to invoke with index of button pressed
'confirm alert Box', // title
'ok,Cancle' // buttonLabels
);
}
function onConfirm( button ){
if( button == 1 ){
alert("Ok button is clicked");
}else{
alert("cancel button is clicked");
}
}
while button is clicked and we press the ok or cancel button then immediately confirm alert box is displayed for second time for very small amount of period.
I am wondering that why the confirm alert box is displayed for second time.
Please give me solution for that.
I need help detecting and dealing with the home button being pressed on a iPhone/iPod Touch running an AIR app. I tried
NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleKeys, false, 0, true);
function handleKeys(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.HOME) {
//do something
}
}
without luck. Any ideas? Specifically, I want to prevent the app from closing when the home button is pressed.
import flash.events.Event;
addEventListener(Event.ACTIVATE, activateListener);
addEventListener(Event.DEACTIVATE, deactivateListener);
private function activateListener(e:Event):void{
//do something when awakened
}
private function deactivateListener(e:Event):void{
//do something when home button is pressed.
}