Focus lost when Fullscreened in chrome app

618 Views Asked by At

I created a simple chrome app which has only one text div element by id "sample". I'm testing on chromebook. The problem is this:

  1. I typed few keys in text input.
  2. I pressed the full screen button in Chromebook.

The focus on the text input element is lost.

This is the function i'm using to create the chrome app window

chrome.app.runtime.onLaunched.addListener(function() {
  chrome.app.window.create('index.html',
    {'bounds': {'width': 500, 'height': 309}});
});

I wrote a small javascript code to handle the full screen issue. But this is not working:

chrome.app.window.current().onFullscreened.addListener(function(){ 
      var textbox = document.getElementById("sample");
      textbox.focus();
  });

Please help.

1

There are 1 best solutions below

0
On

Put a call to console.log in your onFullscreened handler to verify that it's being called. The current() method returns an AppWindow object, which is certainly not what you want to attach the event handler to. Perhaps the contentWindow property of the AppWindow is what you want. Try that.