← Back to team overview

ubuntu-phone team mailing list archive

Re: Triggering on-screen keyboard with HTML5 SDK

 

On Wed, Mar 26, 2014 at 3:04 PM, Robert Schroll <rschroll@xxxxxxxxx> wrote:

> Here's a test case that demonstrates both of these issues:
> http://paste.ubuntu.com/7158427/
>
> Clicking on the "Click here" text focuses the text input.  This works in
> the browser, the HTML5 launcher, and the device (or, the emulator, at
> least).  In this last case, the OSK appears as desired.  But the fact that
> there's a click is important.  In a previous test case, I made the focus
> happen after 5 seconds.  If you had clicked anywhere, you'd get the OSK; if
> not, you'd get focus without the keyboard.
>
> Once focus is on the input, the keydown, keyup, and keypress events will
> trigger text to be added to the three bottom lines.  This works in the
> browser and in the HTML5 launcher, but it does not work on the device (er,
> emulator).


they are not supported yes w/ the OSK, but you can still make it work by
trapping the 'input' event:

document.querySelector("input").addEventListener('input', function(e) {
console.log(e.target.value); });




> On Wed, Mar 26, 2014 at 2:22 PM, Alexandre Abreu <
> alexandre.abreu@xxxxxxxxxxxxx> wrote:
>
>> Hi Robert,
>>
>> On Wed, Mar 26, 2014 at 1:56 PM, Robert Schroll <rschroll@xxxxxxxxx>
>> wrote:
>>
>>> On Tue, Mar 25, 2014 at 5:10 PM, Robert Schroll <rschroll@xxxxxxxxx>
>>> wrote:
>>>
>>>> On Tue, Mar 25, 2014 at 10:04 AM, Alexandre Abreu <
>>>> alexandre.abreu@xxxxxxxxxxxxx> wrote:
>>>>
>>>>> Hi Robert,
>>>>>
>>>>> The gist of the issue is OSK not popping up when js sets the focus in
>>>>> a text field.
>>>>>
>>>>
>>>> I'll agree that fixing this would be enough for me to get by with.
>>>>
>>>
>>> I've played around with this a bit more, and it seems that the OSK fails
>>> to appear only if you try to activate it before the user has interacted
>>> with the WebView.  While this is a problem in general, I escape as I only
>>> want the OSK for an inner page of the application.
>>>
>>
>> afaik (and I have to further validate it), it fails to appear when js has
>> set the focus to a given (text) element and the user clicks on the text
>> element, no OSK pops up unless the user manually forces the focus elsewhere
>> and back to the text field,
>>
>>
>>>
>>> So I've added a dummy text input to my HTML to act as my focus trigger.
>>> It doesn't work with display: none, but I can make it a pixel big and toss
>>> it somewhere out of the way.  (If I make it zero pixels in size, the web
>>> process crashes.)  But -- pressing OSK buttons while this has focus doesn't
>>> seem to generate any key events, either for the document in general or for
>>> the input specifically!  Is this a known problem?  Is there a work around?
>>>  Or is there a different set of events to which I should be listening?
>>>
>>
>> I'll give it a try, but it should work; are you sure the events are not
>> caught by some element?
>>
>>
>>
>
>

Follow ups

References