Javascript touchend event will not fire on Android - javascript

I'm trying to use the touchend (or the taphold event, both wont fire) as specified by jquery mobile. I'm developping an app for android using the phonegap platform. My AVD runs Android 4.0.3, and my phonegap version is 1.3.0.
As im using phonegap, i'm coding in javascript, and the objective is to recuperate the text selected by the user after a longpress on a word with the following code.
var selectAction = function(){
LOGGER.log('event.js : selectAction');
};
function selectMobile(component){
component.addEventListener('touchend',selectAction,false);
}
It actually works fine, if I tap relatively quickly, the event will fire up and I can get the log message. However, a rapid touch will not select text (I have more code taking the selected text but this is not the issue)
When a user long presses in Android, a default ''Action Menu'' pops up, and this seems to block further events from firing up. Because of that, I never get into my selectAction when actual text is selected.
Does anybody know how to properly get selected text in an html/javascript on an Android platform ?
Thank you very much.

It's could be related to below bug.
http://code.google.com/p/android/issues/detail?id=19827
try catch touchmove and call e.preventDefault()

Related

How to handle Samsung S-Pen button event in the browser (Javascript)?

I'm developing a web app for the Galaxy Tab S3 that allows the user to draw with a Samsung S-Pen. The S-Pen has a button on the side which I know can be used by native Android applications to perform various functions. However, I am having a hard time figuring out how to identify which event gets fired in the browser when this button is pressed (or even if an event is fired?).
I have tried out all of the PointerEvents and TouchEvents and I tried identifying an event here: https://patrickhlauke.github.io/touch/
I also found nothing in the S-Pen SDK:
https://developer.samsung.com/galaxy-spen-remote/overview.html
And unfortunately this post was removed:
https://stackoverflow.com/questions/51489489/detecting-pen-stylus-button-events-in-javascript
Does anybody know the name of the event or where I can figure this out?

iOS Keyboard Partial Trigger on input focus

When the using the site in Safari on iPhone 5/SE, focusing on either of the two inputs shown below doesn't fully trigger the keyboard. The field toggle and "Done" buttons appear but no keyboard.
We're using a third party chat plugin that we can't swap out for another one.
The live site is: https://www.citywesthousingtrust.org.uk
I'm using the iOS simulator here but it works the same on the physical devices we have too. The issue appears to be limited to iPhone 5/SE.
Any ideas?
The simulator does this because you have a physical keyboard on your mac so no need to display anything (you can type using your computer keyboard).
If you explicitly need the iOS keyboard to show up, press 'command + K' when you're in the simulator
Hope this helps!

I have to click twice to activate any button action (Ionic/Angular)

I have an app which is an Ionic Project.
in android it is working fine. But when I build and run the project in ios I have to click Every button twice (double tap) in Simulator and in Device also.
I don't know what exactly is the issue. and how to debug.
Is their someone who knows what to do ?
Edit this is happening for Buttons and a tag.
I put this CSS:
.button:hover
{background-color:red;}
and when I run my project and click on button then this :hover css is applied and click event not triggers.
On iOS devices, I believe the first touch is seen as 'hovering' in a similar way to when you hover over something with your mouse. Essentially, the first touch on iOS is seen as hover and the second is seen as a real click.
You can listen for .hover events instead of .click events based on the browser, which will be Safari on iOS and Chrome on Android. Although some iOS devices may be running chrome, this could work for the majority of the cases, assuming it is possible with Ionic.

HTML Button in iFrame does not work properly on iPad

I have a web application in which I have a div element with an onclick javascript action. This web application works fine on iPads and desktops alike.
When it is launched within an iFrame on an iPad, however, all of the sudden, my clicks/taps are rarely and inconsistently acted upon. When running in an iFrame on a desktop browser, I do not see this behavior.
Has anyone seen this type of behavior before?
I'm not sure about your exact situation, but I was having a similar problem when my botton had a "mouseenter" event trigger binded to it. The mouse enter would be called on the first "tap" and the button would be called on the "second". Because of the way ipad uses those two events.
My solution was to use the browser detection tool from http://detectmobilebrowsers.com/ and set a var ismolible = to true or false, depending on whether the browser was mobile or not, then I used an if statement to unbind my mouseenter immediately if the browser was mobile. You do have to modify the http://detectmobilebrowsers.com/ code for ipad.
Hope this helps!

How to capture the hide keyboard event on iOS using JavaScript

I need to do some resizing of the content of a web page when the hide keyboard button is pressed on an iPad virtual keyboard. Which JavaScript event is launched when the keyboard is hidden?
You can use the focusout event. It's like blur, but bubbles. It will fire when the keyboard closes (but also in other cases, of course). In Safari and Chrome the event can only be registered with addEventListener, not with legacy methods. Here is an example I used to restore a Phonegap app after keyboard dismissal.
document.addEventListener('focusout', function(e) {window.scrollTo(0, 0)});
Without this snippet, the app container stayed in the up-scrolled position until page refresh.
Here is a good place to start List of supported Javascript events on iPad
which leads to https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW5
which does not list it.
This one gives a work around iPad Web App: Detect Virtual Keyboard Using JavaScript in Safari?
window.onblur = function(e) {
window.scrollTo(0, 1);
};
This is my solution, which works fine, if someone pressed the "closekeyboard" for iOS 14.7 .

Categories