I'm having some issues with the softkeyboard behaviour in flex 4.6 and air 3.1
I have a list with a search bar on top. When a user selects the TextInput component the softkeyboard pops up like it should.
Now when the user is done typing his text and presses the return (or the done/search/...) key I want the softkeyboard to disappear.
What I've tried so far:
I've set the returnKeyLabel property to "done" and the button shows
up accordingly. However it only dismisses the keyboard on Android, on
IOS the keyboard just stays up.
I then tried by not setting the returnKeyLabel and manually
catching the Return key and setting the focus to another element that
does not require a softkeyboard but that didn't work either.
I also tried by dispatching my own "faked" click events when the Return key was pressed but this also didn't work.
As part of searching about this problem I found this Dismiss SoftKeyboard in Flex Mobile but that didn't work either. Or at least not in flex 4.6
Now does anyone know of a good way to hide the softkeyboard or make the returnKeyLabel "done" work on IOS that will work with flex 4.6/air 3.1?
Have you tried something like this?
<s:TextInput prompt="First Name" returnKeyLabel="done" enter="handlerFunction()"/>
private function handlerFunction():void{
stage.focus = null
}
For flex mobile android apps I have mimicked the intuitive ios way of tapping on the background to remove the softkeyboard as follows:
import spark.components.supportClasses.*
protected function application1_clickHandler(event:MouseEvent):void
{
if(event.target is StyleableTextField || event.target is StyleableStageText){
// ignore because came from a textInput
}else{
stage.focus = null
// to remove the softkeyboard
}
}
<s:TextInput prompt="First Name" returnKeyLabel="done" enter="{stage.focus = null}"/>
This is the same as Francis' answer, but it saves having to make a new function
Related
I use C++ Builder Tokyo 10.2.3 and trying to do something very simple on Android like typing some text into an Edit box.
If I press Next or Done key on virtual keyboard everything is fine.
If I press an Exit Button to go back the previous form it looks it is fine but then if I press Android Back button application crash.
It took me hours to identify the problem but couldn't find any solution but trying to disable all other objects when user clicks in an Edit box and enable them if user click on Next..
It seems to me a bug but need to make sure before report it to Embarcadero.
Thanks
I found the problem and a solution. In short, there is a bug in C++ Builder Tokyo 10.2.3 as if virtual keyboard on Android hide/close because of focus change on a form virtual keyboard doesn't take it as it is hidden properly.. FormVirtualKeyboardHidden working fine but I don't know somehow application crashes.
So, the solution is to using platform services. Just hide the keyboard manually on FormFocusChanged event.
void __fastcall TForm1::FormFocusChanged(TObject *Sender)
{
di_IFMXVirtualKeyboardService VirtualKeyboardService;
if(TPlatformServices::Current->SupportsPlatformService(__uuidof(IFMXVirtualKeyboardService), &VirtualKeyboardService))
{
VirtualKeyboardService->HideVirtualKeyboard();
}
}
When I write into a line edit using the Android keyboard, and I press the "Done" button (screenshot below), the keyboard does not disappear. This happens even in a newly created project with just a line edit (I tested it).
How can I make "Done" to hide the keyboard?
Please note that I am looking for a developer solution (i.e. programming, not user oriented) and a native way (i.e. C++/Qt, not Java).
I'm using Qt 5.2.0.
You have to call the QInputMethod::hide() slot.
C++ Solution
connect(ui->lineEdit, SIGNAL(editingFinished()), QGuiApplication::inputMethod(), SLOT(hide()));
QML Solution
TextInput {
Keys.onEnterPressed: {
//...
Qt.inputMethod.hide()
}
Keys.onReturnPressed: {
//...
Qt.inputMethod.hide()
}
}
The Issue:
Using
<input id="my_tel" type="tel" onkeypress="alert(event);"/>
<input id="my_num" type="number" onkeypress="alert(event);" />
The issue is that pressing done or enter or go key in android, nothing happens.For all other keys it works fine. When i tried to alert what event is being fired i found none.
The keypad does not hide (which is very sad) on pressing go/enter/done button.
However using
input type="text"
the issue does not exist.
Here is what i tried :
A. Used input type="text" and do not allow user to enter anything except
numbers.
Problem with this approach : The user is always presented with the default textual keyboard, and she/he has to switch, from default text to number pad,
which is not elegant and a turn off as i have many such pages in my project.
B. Used events like 'touchstart'and 'touchend' but no luck.
C. The input box is not even losing focus on key press so the solution
html phonegap android : numeric soft keyboard has next instead of go button is not useful.
Possible solution :
We can use the SoftKeyBoard plugin (https://github.com/phonegap/phonegap-plugins/tree/master/Android/SoftKeyboard). And hope that this problem is solved by this. But seriously can't there be a better solution??
Note : The problem is not observed in the iOS app,just android.
Another Note : No DOM event is fired even on pressing backspace key, but atleast the the backspace key is doing its job. In my case the done/go/enter key does not seem to execute its default behavior.
are you using iScroll?, if you are try removing it for a quick test and see what happens. I use it on a phonegap app and it's doing strange things with the inputs.
I've seen/heard all about disabling text selection with the variations of user-select, but none of those are working for the problem I'm having. On Android (and I presume on iPhone), if you tap-and-hold on text, it highlights it and brings up little flags to drag and select text. I need to disable those (see image):
I've tried -webkit-touch-callout to no avail, and even tried things like $('body').on('select',function(e){e.preventDefault();return;}); to no avail. And the cheap tricks like ::selection:rgba(0,0,0,0); won't work either, as hiding these won't help - selection still happens and it disrupts the UI. Plus I'm guessing those flags would still be there.
Any thoughts would be great. Thanks!
-webkit-touch-callout:none;
-webkit-user-select:none;
-khtml-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
-webkit-tap-highlight-color:rgba(0,0,0,0);
This will disable it for every browser going.
Reference:
jsFiddle Demo with Plugin
The above jsFiddle Demo I made uses a Plugin to allow you to prevent any block of text from being selected in Android or iOS devices (along with desktop browsers too).
It's easy to use and here is the sample markup once the jQuery plugin is installed.
Sample HTML:
<p class="notSelectable">This text is not selectable</p>
<p> This text is selectable</p>
Sample jQuery:
$(document).ready(function(){
$('.notSelectable').disableSelection();
});
Plugin code:
$.fn.extend({
disableSelection: function() {
this.each(function() {
this.onselectstart = function() {
return false;
};
this.unselectable = "on";
$(this).css('-moz-user-select', 'none');
$(this).css('-webkit-user-select', 'none');
});
return this;
}
});
Per your message comment: I still need to be able to trigger events (notably, touchstart, touchmove, and touchend) on the elements.
I would simply would use a wrapper that is not affected by this plugin, yet it's text-contents are protected using this plugin.
To allow interaction with a link in a block of text, you can use span tags for all but the link and add class name .notSelected for those span tags only, thus preserving selection and interaction of the anchors link.
Status Update: This updated jsFiddle confirms you concern that perhaps other functions may not work when text-selection is disabled. Shown in this updated jsFiddle is jQuery Click Event listener that will fire a Browser Alert for when the Bold Text is clicked on, even if that Bold Text is not text-selectable.
-webkit-user-select:none; wasn't supported on Android until 4.1 (sorry).
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.