I am creating an iPad app in which I have a textInput component that when it is in focus is suppose to call a callout with a spinner in it. The problem is that the softkeyboard is showing up every time I touch the textInput component. I have tried everything I could find which includes the following:
private function onActivating(event:SoftKeyboardEvent):void
{
event.preventDefault();
}
<s:TextInput softKeyboardActivating="onActivating(event)" />
and
<s:TextInput needsSoftKeyboard = "False"/>
Both of these examples are still having the softkeyboard show up.
Have you tried to simply disable the TextInput and change the styles so it doesn't look disabled? Touch events may not trigger though but short of styling a label [as suggested above] you'll have to do some trickery one way or another.
Related
I am trying to build a simple messaging view in ionic. My view looks as follows:
Initial screenshot
My problem is when I focus the input on iOs, the keyboard covers the input, however on an Android device, the input moved along with the appearing keyboard as expected.
My understanding that if I use position: fixed and indicate bottom value (say, bottom: 16px) the input should appear 16px above the page fold both when the keyboard is open and when it isn't.
For reference, this is the result I get when I try to focus the input on an actual iOs device.
On-screen keyboard covers up input
I had this problem with ion-textarea. I'm using ionic 4 beta 17 - ionic keyboard 2.1.3
I am still not using native keyboard, but maybe will try.
What I did is hookup the keyboardDidShow event and scrolled the active document into view. Look at this code:
ngOnInit() {
window.addEventListener('keyboardDidShow', () => {
const el = document.getElementById('myElement');
//myElement would be the input you have. Or you can just scroll into view the active element, like
// document.activeElement.scrollIntoView();
if (document.activeElement === el)
el.scrollIntoView();
});
}
I want to create a button-like component with ripple animation and it looks like this:
<div>Button</div>
<material-ripple></material-ripple>
In the past, this works fine because when I click on this custom element, I actually clicks on material-ripple and the click event bubbles to the host element.
As of angular_components 0.5.1, material-ripple shows a centered ripple on keypress. This is different from clicking because the event target is the host element itself and not the ripple component.
Is there a way that I can pass a keypress event down to the material-ripple, so that the ripple animation would be played? Or is there a way to play the animation programmatically?
After some research, I've come up with a solution using dart:html.
#ViewChild(MaterialRippleComponent, read: ElementRef)
ElementRef materialRipple;
#HostListener('keydown', const [r'$event'])
void passKeyDown(KeyboardEvent event) {
(materialRipple.nativeElement as HtmlElement).dispatchEvent(
new KeyEvent('keydown', keyCode: event.keyCode, canBubble: false)
.wrapped);
}
Although this does not work in Dartium due to some bugs around KeyEvent and KeyboardEvent, it works fine in Chrome.
I want to keep the keyboard displayed at the bottom by default without using a text input which the user needs to tap.
I need to keep the keyboard at the bottom at all times.
Then I need to listen to the events of the keyboard.
How can I do this?
The workaround I implemented was adding an invisible text box somewhere on the screen and then set it as focused manually.
Just in case someone else might stumble upon this, OP's self answer works. In order to set focus manually, you'll need to get the ref to the hidden input.
<TextInput
ref={input => (this.textinput = input)}
style={{ display: 'none' }}
/>
then elsewhere in the code, you focus manually by
if (this.textinput) {
this.textinput.focus();
}
This answer is way too late to do the OP any good, but for others:
You can't do this. In iOS, the operating system, keyboards simply don't/can't work this way. iOS never shows a keyboard without an active text input focus, and there is no way for even a native iOS app to override this OS-level behavior. The OS itself prevents this from happening.
I'm using JQuery Mobile within a PhoneGap IOS App. I'm currently successfully capturing the IOS Keyboard return within a search key as follows.
JS
function blah()
{
if(window.event.keyCode == 13 )
{ do something }
}
HTML
<input type="search" id="searchBox" value="" onblur="dothis()" data-inline="true" onKeyPress="blah();" />
I would like to capture the 'Done' key on the keyboard as well. I cant seem to find any information on this.
Thanks.
Unfortunately, pressing the "Done" key does not fire a keyCode event. So, I can't seem to find a way to detect it either.
I think the only option is to detect the "blur" event on your field. If the event occurs, then fire whatever action you need. Of course, this is only useful if you have a single field. If you have more than one field, using "blur" to be the equivalent of "Go" or "Submit" is useless.
Let us know if you found a better workaround.
I've suggested using the blur event in my original answer. However, I think a better idea is simply to listen for the keyboard hiding - which will happen after the "Done" button is pressed.
window.addEventListener('keyboardDidHide', function () {
// Describe your logic which will be run each time keyboard is closed.
});
https://github.com/cjpearson/cordova-plugin-keyboard#keyboarddidhide
Also, be sure the deregister this listener after you've done whatever you need to do after the keyboard hides. Otherwise, it will fire every time the keyboard hides in other parts of your app.
On Phonegap application, is there any way to prevent page scrolling when a text-input is focused and the soft keyboard shows?
In case of no way, Is there any way to scroll the page to the position of text input instead of 'bring' the text input onto center of screen?
in phonegap 2.6 there is a new option to prevent scrolling by resizing the webview. take a look at the documentation and find the KeyboardShrinksView option.
cheers
I've used this javascript code with some success. It overrides the window.scrollTo function and cancels it out...
window.oldScrollTo = window.scrollTo;
window.scrollTo = function (x, y) {
console.log("window.scrollTo");
return;
};