¿Muestra programáticamente el teclado virtual en iPhone en una aplicación PhoneGap?

He estado buscando mucho y mucho tiempo, y hasta este momento, no encontré unsolución de trabajo para aplicaciones de PhoneGap / Cordova que mostrarían un teclado suave mediante programación.

Guión:

Tenemos una aplicación PhoneGap, un sitio web creado en jQuery Mobile, que en un momento muestra un diálogo al usuario. Este cuadro de diálogo también es una página web y tiene un solo cuadro de texto ENTRADA donde el usuario debe ingresar un código.

Problema:

Cuando se muestra el diálogo de código, elel cuadro de entrada está enfocado usando JavaScript. Sin embargo, debido a las restricciones impuestas en el navegador interno del iPhone, el teclado virtual no se activa hasta que el usuario realmente hace clic dentro del cuadro de texto de entrada.

Lo que intentamos:

creando uncuadro de texto oculto y haciéndoloprimer respondedorhaciendo lo realwebview un primer respondedor Una vez que la entrada recibe el enfoque a través de JavaScriptutilizandosendActionsForControlEvents para probar y ofrecer eventos táctiles a la vista web (aunque si alguien tiene un código de trabajo para una aplicación de PhoneGap, agradecería que lo compartiera, ya que no soy un profesional en la codificación de iOS)

¿Algunas ideas?

EDITAR: La restricción mencionada en esta pregunta es paranavegadores incorporados solo ... si apuntas a Opera, tendrás éxito usando el siguiente código:

var e = jQuery.Event("keydown", { keyCode: 37 });
$('#element').focus().trigger(e);

EDIT2: Este es un código de PhoneGap final que puede usarse en un complemento:

keyboardhelper.h

//
//  keyboardHelper.h
//  soft keyboard displaying plugin for PhoneGap
//
//  Copyright 2012 Martin Ambrus.
//

#import <Foundation/Foundation.h>
#ifdef CORDOVA_FRAMEWORK
#import <Cordova/CDVPlugin.h>
#else
#import "CDVPlugin.h"
#endif

@interface keyboardHelper : CDVPlugin {
    NSString *callbackID;
}

@property (nonatomic, copy) NSString *callbackID;

- (void)showKeyboard:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;

@end

tecladohelper.m

//
//  keyboardHelper.m
//  soft keyboard displaying plugin for PhoneGap
//
//  Copyright 2012 Martin Ambrus.
//

#import "keyboardHelper.h"
#import "AppDelegate.h"

@implementation keyboardHelper
@synthesize callbackID;

-(void)showKeyboard:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options {
    self.callbackID = [arguments pop];

    //Get text field coordinate from webview. - You should do this after the webview gets loaded
    //myCustomDiv is a div in the html that contains the textField.
    int textFieldContainerHeightOutput = [[((AppDelegate *)[[UIApplication sharedApplication] delegate]).viewController.webView stringByEvaluatingJavaScriptFromString:@"document.getElementById(\"myCustomDiv\").offsetHeight;"] intValue];

    int textFieldContainerWidthOutput = [[((AppDelegate *)[[UIApplication sharedApplication] delegate]).viewController.webView  stringByEvaluatingJavaScriptFromString:@"document.getElementById(\"myCustomDiv\").offsetWidth;"] intValue];

    int textFieldContainerYOffset = [[((AppDelegate *)[[UIApplication sharedApplication] delegate]).viewController.webView  stringByEvaluatingJavaScriptFromString:@"document.getElementById(\"myCustomDiv\").offsetTop;"] intValue];

    int textFieldContainerXOffset = [[((AppDelegate *)[[UIApplication sharedApplication] delegate]).viewController.webView  stringByEvaluatingJavaScriptFromString:@"document.getElementById(\"myCustomDiv\").offsetLeft;"] intValue];

    UITextField *myTextField = [[UITextField alloc] initWithFrame: CGRectMake(textFieldContainerXOffset, textFieldContainerYOffset, textFieldContainerWidthOutput, textFieldContainerHeightOutput)];

    [((AppDelegate *)[[UIApplication sharedApplication] delegate]).viewController.webView addSubview:myTextField];
    myTextField.delegate = self;

    CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: @"ok"];

    [self writeJavascript:[pluginResult toSuccessCallbackString:self.callbackID]];
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
//here you create your request to the server
return NO;
}

-(BOOL)textFieldDidEndEditing:(UITextField *)textField
{
//here you create your request to the server
return NO;
}

@end

javascript

var keyboardHelper = {
    showKeyboard: function(types, success, fail) {
        return Cordova.exec(success, fail, "keyboardHelper", "showKeyboard", types);
    }
};

Respuestas a la pregunta(7)

Su respuesta a la pregunta