When I tap on an inputfield on android device, i get a little text area and an ok button. But I have to touch the input field to get the keyboard to pop up.
Any ideas?
All I'm doing code wise is:
if (!wasFocused && TouchScreenKeyboard.visible && createAccountPanel.activeSelf)
{
wasFocused = true;
btnMat.color = validC;
}else if (wasFocused && !TouchScreenKeyboard.visible && createAccountPanel.activeSelf) {
wasFocused = false;
btnMat.color = invalidC;
//messageMNG.CreateMessage("Checking name: " + usernameChangeInput.text, true);
dbMNG.CheckName(usernamePreview.text);
}
When I do a check, it says that touchscreenkeyboard is visible.
**EDIT
I just created a new scene and added an input field and a text mesh pro input field and I get the exact same thing.
The keyboard does not pop up if you are running the app on Unity Remote app. Keyboard will automatically show up once you build and run your unity app on device.
I was having a similar problem today, but found the reason no keyboard was showing was due to building and launching onto a locked phone. When I made sure the phone was unlocked when I clicked the input, the keyboard showed up below that box/ok portion.
Related
I am using Unity in my Android project. There are input fields in my app. As soon as I click on the field the keyboard pops up. I want the keyboard to only show up when there is a double-tap on the field. But I am not able to get it to work and I have tried several ways.
Requirement 1: Single tap shouldn't open keyboard
Requirement 2: Double tap should open keyboard
I tried OnPointerClick method of IPointerClickHandler but this doesn't seem to work. I used this code in one of the scripts attached to input field with IPointerClickHandler.
public void OnPointerClick(PointerEventData eventData)
{
if (eventData.clickCount == 2)
{
Debug.Log("UNITY - Double click");
}
else if (eventData.clickCount == 1)
{
Debug.Log("UNITY - Single click");
}
}
Then there is also the question of how to hide the keyboard or prevent it from opening on single tap. This also I am not able to solve. I started with clicking the Hide Soft Keyboard in control setting of InputField in Unity editor. But surprisingly this starts opening a keyboard which has mobile input.
Can someone help? I have been stuck on this for some time I can't seem to be getting anywhere.
I have an android device with an integerated barcode scanner. The main reason is, that I want to avoid that the keyboard always pops up when im automatic focusing the input field. So my idea was it, to use an HostListener in the background and trigger every input. Now I noticed that the HostListener works only when the keyboard is shown, which actually mean that im focusing the input field. When im testing it in the browser, I dont need to be focused on the field. Has the android webview here some special things, which I dont see at the moment?
Thats my HostListener
#HostListener('input', ['$event'])
onKeyDown(event: KeyboardEvent) {
var input = event.target as HTMLInputElement;
alert(input);
}
EDIT
I found a new way, and strangely enough this method gets called when im using the scanner, but now I have the problem that I get the issue which says e.keyCode and e.target does not exist on type '{}'. I tried already e as KeyboardEvent and e as InputEvent, but that also not working. But when im checking the object in the browser, it is definitly the right object, but I cant access it.
this.subscription = Observable.fromEvent(document, 'keypress').subscribe(e => {
if(e.keyCode == 13) {
console.log("called");
}
})
this.subscription = Observable.fromEvent(document, 'input').subscribe(e => {
var input = e.target as HTMLInputElement;
console.log(input.value);
})
If I load a large html file in a webview running Android 4.0.4 and then press on an input in that webview it works normally. However, when I click a button on the keyboard ("a" or even using voice input) the whole screen goes white and only the input that was initially selected can be seen by the user.
This works perfectly fine in 4.0.3 and 4.1. It only happens in webviews that are longer than the screen (i.e. scrolling required).
I came up with this, after variable trying.
The reason is you do your stuff before input.onblur finishes its work.
So one of the solution is just wrapper your stuff with setTimeout()
here is an example
var ipt = document.createElement('input');
ipt.type = "text";
document.body.appendChild(ipt);
ipt.onkeyup = function(e){
e=e||window.event;
var key = e.keyCode || e.which,
ipt = e.target || e.srcElement;
if(key==13){
ipt.blur();
setTimeout(function(){
//DO YOUR STUFF HERE !!!
}, 100);
}
}
I am trying to capture input events on a text input. Using jQuery I am handling the keyup event to populate a list of matches (an auto-complete list). This works fine on the stock browsers and others such as Maxthon, but in Firefox mobile nothing happens while the keyboard is shown--I have to either press enter or hide the keyboard for it work work.
I am using jQuery 1.7.2, Android 2.3 and the latest version of Firefox (10 I believe). I have also tried other events such as input and keydown without any luck.
Is it possible to handle key/input events in Firefox mobile while the keyboard is shown?
The problem is that when word suggestions are turned on in the Android keyboard, Firefox is not triggering the key events during the time the keyboard is "guessing" words, although the values are sent to the text field. I would say this is a bug in Firefox, but I guess they have chosen to do it this way because the result of the key pressed is not consistent with the value the field gets if the keyboard suggests something different than the exact thing you write.
I solved this by using a sniffer that checks on the value if it has changed or not.
var $searchField;
var _keypressWatchingTimer = 0;
var _previousTerm = '';
function keypressStartWatching() {
keypressStopWatching();
_keypressWatchingTimer = setInterval(executeAutocomplete, 100);
}
function keypressStopWatching() {
if (_keypressWatchingTimer != 0) {
clearInterval(_keypressWatchingTimer);
_keypressWatchingTimer = 0;
}
}
function executeAutocomplete() {
var searchTerm = $searchField.val() || '';
if (_previousTerm == searchTerm)
return false;
searchApi.autocomplete(searchTerm);
_previousTerm = searchTerm;
}
function init() {
$searchField = $('#searchField')
.focus(keypressStartWatching)
.blur(keypressStopWatching)
.keyup(executeAutocomplete);
}
init();
does anybody knows how to force keyboard open on android browser (4.0 - maybe less)?
i tried this solution and it does not worked for me.
in project i am trying to get a text input working, but after submitting (intercept by jQuery) it holds focus but the keyboard disappears.
snippets:
$('#typer').blur(function () {
$(this).focus().click();
});
$('#typer').bind('keyup', function (e) {
var input = $.trim($(this).val());
// some lines of code..
$(this).val('').focus(); // clean up
}
iOS is also interesting.. but not tested yet.
Android pulls up soft keyboard whenever text input field is in focus. "Go" or "Done" button on Android works as form submit, therefore input text looses focus and keyboard disappears. User expects the keyboard to disappear after "Go", "Done" or "Enter" is pressed - so Android follows this rule. Forcing re-focus on field's blur will not do much since technically you moved to a different window.
$('body').click(function() { $('#typer').focus(); }
can provide a partial solution, whereby user has to click once anywhere in the body of the page for the typer to re-gain focus. It causes OS to move back to browser Activity and focus the input field. This fiddle shows it as an example: http://jsfiddle.net/Exceeder/Z6SFH/ (use http://jsfiddle.net/Exceeder/Z6SFH/embedded/result/ on your Android device)
Other than writing a PhoneGap-like wrapper to control imeOptions of the keyboard, I am not aware of any solution that can solve this problem.