Accesing softkeyboard buttons with Phonegap - javascript

i have developped a mobile app with dojo and phonegap for android. The problem is, that I want to acces the bottom right corner button. I want to change its name to "send" and I want to connect the button with a function. Does anyone have an idea how to do that? Using javascript, or how to do that natively?

Natively it is possible to change the text to certain other limited options however I doubt whether it is possible to do from the context of a PhoneGap app.
Check this post which details the process of doing relatively same but in native.
Android - Handle "Enter" in an EditText
For more detail you need to check the doc

Related

How can I get a WKWebView to show the keyboard on iOS?

My iOS app uses a WKWebView with contenteditable = true on a specific div. I'd like to have code to make the keyboard show up for the web view, so the user can just start typing. Things I've tried that have had no effect:
Telling the web view to becomeFirstResponder (a long shot, because the web view wouldn't know what div to use).
Injecting JS to tell the div to focus(). (This works in other browsers, but sadly not in WKWebView)
Simulating touch events in JS via TouchEvent and dispatchEvent() in the hope of making it seem that the user had tapped on the div.
In the third case I also used addEventListener() to observe the simulated touches and compare them to real touch events from tapping the screen. It looks like the key difference is that the event's isTrusted value is false for the simulated touches.
I get that it's a potential security issue to let apps simulate touch events, but I didn't have any other ideas. I'm trying to get the keyboard to appear, what the user types is up to them and not something I want to mess with. Basically I want the same thing as calling becomeFirstResponder() on a UITextView.
This is very similar to a WebKit issue 142757 but I haven't figured out how to use the suggested workaround linked from there.
Clarification: I can set up and use an editable web view, but the keyboard doesn't appear until I tap on the web view. I'm trying to make the keyboard appear automatically, without requiring a tap to initiate editing.
I tried this in an iPad playground, and it works without any action on my part. It’s possible there is another view that is capturing touches, or “contenteditable” is misspelled, or something else?

Capture barcode reader event on Honeywell 75e and phonegap

I am trying to create an android application with phonegap and Cordova. I have got a Honeywell device 75e on which the app will be running. I have got to the point where by which if I press the scan button on the device, the bar code gets printed into the textbox which is in focus. However what I want to do is that when the scanner button is pressed and the bar code has been read using the internal scanner on the device, the application should go to the next page. I was thinking of adding a on key event on the input box itself but I cannt really do that as the user of the application can type the text in the textbox and then press the go button.
Is there a way to find out the keycode for the scanner button on the device and if there is then I could modify the application to look for the key code and fire the fake button click event.
Any help here would be much appreciated.
I think I have figured it out how to get around this but posting it here for anyone who is stuck as well. If you log into the honeywell technical support portal, (login is free) you can get the web API SDK which allows you to communicate with the hardware. It adds listeners to the bar code and also has additional functions.

how to call or mimic a javascript function inside a webview

I am making a hybrid app. I am using xamarin for android, pretty much the same as android. I have already figured out how to hook the phone's back button press. When pressed I want my app code to either mimic or call a javascript function that is part of the webpage that the webview is displaying. It is my web page, so I know the code that the webview is rendering. To be specific, I want to call a jquery slideToggle function on a page element when the phone's back button is pressed. Can that be done, and if so what would be the best approach? I'm hoping that someone here has had to do something just like this in the past. Thanks.
I don't think webview supports JQuery, unless maybe you reference it.
The Xamarin android way of doing it is:
webView.addJavascriptInterface(new JsObject(), "injectedObject");
webView.loadData("", "text/html", null);
webView.loadUrl("javascript:alert(injectedObject.toString())");
Source : Android.Webkit.WebView.AddJavascriptInterface Method
Also make sure you have enabled Javascript,
web_view.Settings.JavaScriptEnabled = true;
You can show or hide the element by finiding it by id (document.FindElementById). Then you can set its display to block or none. Thus you can do it purely in Javascript.
Add on :
There are couple of problems with your method. To name a few -
on pressing of back button user expects a particular behavior and it should not be altered. This would not give a rich user experience.
if you are override ing the back button press then what about the navigation bar menu click.
JavaScript way of doing can cause security issues.

Can I use onclick Javascript in Webview in Android to determine X and Y?

I have made a game in Javascript that I want to make into an Android app.. So obviously using a webView..
I have a function in Javascript that says if you click on the left hand side of the page, the box will move left - if right it will move right etc.
My question is if on my Android phone I click on a specific area of the webView, will it be the same as if I click from a computer?
The reason I am asking rather than showing what I have done, is that I don't want to implement it into Eclipse to find the idea was redundant.
A WebView is like a browser window.
So open your page into the android browser and test, if it works as you wish there, it will most likely work about as good in the WebView.
Don't forget to enable JavaScript for the WebView:
webview.getSettings().setJavaScriptEnabled(true);

How to completely disable soft keyboard for all input in Android webview

I am using phonegap to develop a web app for Android, and since I will have my own keypad in HTML, I need to disable android's system keyboard, preventing the it from showing up when the user clicks on any text input field. I don't want to use readonly input field or onblur() since I would like to have the cursor in the text filed so user can move the cursor position while they're entering inputs.
So I want to completely disable Android's keyboard on default, I tried adding android:windowSoftInputMode="stateAlwaysHidden" to manifest.xml but this does not work.
I also try use a javascript interface from here, but there was a javascript-java bridge crash issue on Android 2.3.x.(link to issue). So I still don't have a good solution now. Please help.
Thank in advance for any help.
Okay, you've got a few options! You can try to disable the keyboard completely using:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
If you choose this way, be sure to return the settings to normal if that's not done automatically. I haven't used this before and couldn't tell you how it behaves, but keep that in mind! You don't want a user to reply to a text they receive while using your app only to have their keyboard disabled :)
You could use something similar to the following link. I haven't dug through it very thoroughly (tl;dr) but he creates a custom view that extends from android.inputmethodservice.KeyboardView and uses that instead.
https://stackoverflow.com/a/1947370/1183256
Lastly (I'm not sure how much this would differentiate from the first one) you could create your own IME.
How to develop a soft keyboard for Android?
http://developer.android.com/guide/topics/text/creating-input-method.html

Categories