Forcing keyboard to display when a text input is selected - javascript

The scenario, I have an input text field I'm doing partial auto-complete on (exactly like the Tags input field on Stack Overflow... because that's what is, basically).
As a user is typing, I suggest things they may typing; the user then clicks one the suggestions, it replaces a bit of the fields content, and places the cursor after where the insert occurred.
All this works, but after the insertion the software keyboard isn't shown anymore. You can replicate this on the desktop Stack Overflow site.
The code on SO isn't exactly the same, though the symptom is.
Here's the actual code called after the text is inserted into the text field.
$(field).focus()[0].setSelectionRange(newCaretPos, newCaretPos);
(Yes yes, setSelectionRange is non-standard; but it works on all the mobile devices I care about just this moment, so ignore it for now)
On android, iphone, etc. this works fine (the keyboard "flickers" but I'm willing to live with it.
So, the question basically boils down to: How can I force the onscreen keyboard to appear on Windows Phone 7 (Mango update)?

Sorry, there is no guaranteed way to force the SIP to display in WP7. :(

Normally setting the focus on the textbox would force the keyboard. Have you tried just setting the focus? (i.e. not setting the selection range)

Related

How to prevent formula touch event in MathJax?

How can I prevent formula touch event in MathJax? e.g. when I touch or click a formula rendered by MathJax It is gone to surround by a blue border as a response that it is touched.
This is an Example form MathJax test folder.
I have already set showMathMenu: false but I am unable to prevent this.
The outline is part of the standard browser interface for focusable items on the page. In version 2.6, MathJax added support for users using assistive technology, and that included making the MathJax menu accessible to keyboard users and those with screen readers. In order for that to work, the math expressions need to be able to accept the browser focus (so that keystrokes will be targeted to them, so the menu can be opened).
The outlines you are seeing are the focus highlighting that is the default styling for focused items in the browser (the actual effect differs between browsers, but all browsers should provide some form of visual indication for the focused item). Without that, keyboard users will not be able to know when and which math expressions are selected for keyboard focus. Removing that would make it harder (or impossible) for those users to properly interact with MathJax and its menus.
While you certainly could add CSS to your page to remove the outlines, it would be a mistake to do so, unless you have no concern for those users who require assistive technology to support their reading of your pages. You should note that all focusable elements should get these outlines (buttons, menus, input areas, etc.) when you click on them. For example, the editor I'm typing into right now has a blue outline indicating that it currently has the keyboard focus. This is part of the standard interface for focusable items, and is not something you should try to disable.

Enable text selection on a website using JavaScript

I know that typing
javascript:void(document.oncontextmenu=null) allows users to enable right click on a webpage
and javascript:void(document.onselectstart=null) should enable text selection if i'm correct?
but I tried typing these on http://www.pcworld.co.uk/gbuk/laptops-netbooks/laptops/apple-laptops/apple-macbook-pro-15-with-retina-display-21576115-pdt.html and it won't work.
by the way I typed it in the console of Google Chrome browser.
#Pointy pointed out that text selection worked fine for him. I tried in a few browsers - in Google Chrome specifically, on mouse down, the cursor changes when one tries to select text on a particular part of the page, and it does not allow this. However, on Firefox, you are perfectly capable of selecting the text.
For your intents, use a different browser and select the text.
For all we know, that sight could have custom javascript and logic preventing text selection, though its pretty lame that it doesn't work cross browser. But this custom logic is probably why your above mentioned commands aren't working.

Why does my token input break on mobile?

You can see my token input here on the search box: http://pineapple.io/
Under normal circumstances, there is a hidden input that expands when you click in the box.
It seems to work great in all desktop browsers, but on a mobile phone when you click in the right area of the box (which normally works on a desktop), it doesnt click inside the tiny invisible input. You need to actually click to the farthest most point (directly to the right of the magnifying glass) and then it will work.
Here is where it must be clicked:
I assume this has to do with the 'touch' rather than click functionality of a phone?
Source is here: http://loopj.com/jquery-tokeninput/
Your input is really small (currently it's hard-coded at width: 30px), hence why the mobile doesn't like it. Can you make that bigger? That would probably help a lot!
Here's a picture to explain:
http://cl.ly/image/0b3N471F1y3O

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

Unable to trigger keyboard on input focus through JavaScript

I'm developing an web application that contains a form with two input elements. One of the user requirements is that after inserting a character into the first input it should automatically trigger the focus of the next element and show the keyboard.
After googling about it seems that isn't possible to programatically trigger the keyboard on iOS through JavaScript. The reason however isn't quite clear to me, some say that is an UX feature but I can't find any official information about it.
So my question is, where can I find some official specs that explain the technical reasons whereby this isn't possible?
Official specs:
http://developer.apple.com/library/IOs/#documentation/AppleApplications/Reference/SafariWebContent/Introduction/Introduction.html#//apple_ref/doc/uid/TP40002079-SW1
Unfortunately, the official specs will not answer your question.
Generally, with forms on iOS safari, the keyboard will stay open until the user chooses to close it. When you auto-focus the next form input, does it close the keyboard?

Categories