I recently designed an app for blackberry with phonegap it works fine except for one issue. The issue is that when i tap outside the form fields(input, submit etc) focus leaves the interface. i want the focus to always be on one of the form fields like in the login page for Facebook app and Twitter app. How can i do this?
You can use set focus() properties.Like that
document.getElementById("Textbox1").focus();
Related
I am accessing an html webapp within a WebView in an Xbox XAML app. For context, it was previously a hosted webapp, but leaks while playing video content were causing crashes, which prompted me to use a XAML app with a WebView and a MediaElement.
Initially, my <input/> fields were not showing the keyboard (InputPane) when focused and pressing the 'A/ok' button on the controller/remote. Using the following
window.Windows.UI.ViewManagement.InputPane
.getForCurrentView()
.tryShow();
helped show the keyboard on first key press. With my app hosted in the WebView, I had the same problem, but window.Windows was not available. The solution seems to be the use the ScriptNotify event on the WebView, that itselfs calls the (very similar) following code in the C# portion of the code:
Windows.UI.ViewManagement.InputPane.GetForCurrentView().TryShow();
So far so good. Now the problem: when hitting the "B/return" button on the controller/remote, the InputPane leaves, and the <input/> element is obviously focused since it still shows a blinking text cursor, but the app does not respond to keypresses. I have to press the "B/return" button a second time to regain control on the webapp.
I looked into the InputPane api, and in hacks like focusing the WebView but without success so far.
Any help is greatly appreciated!
I have been working on this specific requirement for more than 2 months now. But I haven't found a solution yet to disable the native keyboard when an input field is focused in a webview. I am building an app which has a built in keypad(essentially a view) and I want this to be displayed instead of the native keyboard.
What I've tried so far:
Add javascript eventListener for click events to display my keypad
using JavscriptInterface.(Works)
Set the webview focusable:false and
its parent's descendantFocusability to blocksDescendants (This works
but doesn't display the cursor on the input field)
Hiding the native
keyboard on resize event of javascript using loadUrl method.(Works
but the native keyboard is displayed momentarily before hiding the
keyboard)
Listening to the OnGlobalLayoutChange event to check if
the keyboard has been added. (Works but the result is same as
in the case above with a little improve in performance)
Force stop the IME service. (Works but the app has to be a system
app to force stop packages and the keyboard service has to be started
whenever the app goes to background.
Is there a way in which I can make this work?
You should set the windowSoftInputMode to stateAlwaysHidden for the Activity containing the web view. This should keep the onscreen keyboard hidden for the entirety of that Activity.
I am building an Ionic app that presents a form for the user. For one particular field, I'd like to have it such that the user enters data on the field and an event triggers once the user taps anywhere else.
I went for ng-blur and applied it to the tag. Testing it on the browser works perfectly well, however when I simulated the app on the phone, tapping anywhere else did not make any difference. What could be the reason?
I want to be able to show keyboard on mobile browser (e.g. Android) after navigating to the page.
I have already seen some workarounds:
Show virtual keyboard on mobile phones in javascript
Can I trigger Android soft keyboard to open via javascript ( without phonegap )?
Showing Android's soft keyboard when a field is .focus()'d using javascript
But all of these examples work only if user tap somewhere. It allows to trigger focus() from within the click(). Does someone know if there any way to do the same thing but without user clicking?
I've tried to trigger click programmatically but it also not working. http://jsfiddle.net/alex_myronov/e5JcP/10/
My current answer to this is no, can't be done. The script that calls focus() click() on an input needs to be running with user context, ie. triggered by a user interaction. After fairly dedicated fiddling, I've found no way round this.
I managed to successfully open the virtual keyboard by just calling focus() method of the input.
It works in my app both on android 2.3 and 4.1.
I think the trick is that you have to wait untill the page is completly rendered before you call focus().
My app is using jquery mobile and I call focus() when the pageshow event is triggered:
$("#myPage").on("pageshow", function( event ) {
$("#myPage").find('input:first').focus();
} );
Or maybe it's working because I'm in a phonegap app?
I realized that iOS is not working on a form that you can close the application.
I work with PhoneGap version 2.2.0 and I do like to have my application exit button,
I thought about the possibility to move the app to the background and back to the iPhone home page when you click on the button to exit.
I did not find how to do it through PhoneGap
is there a way?
Take a look at this post: https://gamedev.stackexchange.com/questions/17709/can-an-ios-application-have-an-explicit-quit-button
It is quite possible, maybe even likely, that Apple will reject your app for doing this. It should be sufficient for users to close the app simply by pressing the home button.
UPDATE: Just because Android has a button for you to close the app does not mean that one is needed on the iOS version. As other posters have said, conventions are different between the two operating systems.
There is already a button to exit -- the home button on the device. You do not need to add one in your application.