• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

HTML Panel document.onfocus/onblur?

Participant ,
Feb 21, 2018 Feb 21, 2018

Copy link to clipboard

Copied

Having this code:

document.onfocus = function(e) {

console.log("document onfocus " + e)

}

document.onblur = function(e) {

console.log("document onfocus " + e)

}

document.querySelector("body").onfocus = function(e) {

console.log("body onfocus, document hasFocus " + document.hasFocus())

}

document.querySelector("body").onblur = function(e) {

console.log("body onblur, document hasFocus " + document.hasFocus())

}

I can see that when click on my panel and then I alt-tab from photoshop body looses focus and log message states that document had focus.

If I just alt-tab – document didn't have focus.

So document focus state does change.

The problem is that `document.onfocus/onblur` are never called when focus state changes.

Why?

My problem:
I am using Shift modifier key as hotkey in my HTML panel. When panel is not in focus keycode isn't sent to the panel. I understand there is no workaround for keycodes, so I want to display a un-focused state so users would understand that they have to click on the panel to make it focused.

Panel would loose focus if you click on another panel, eg. Layers

TOPICS
Actions and scripting

Views

314

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation
Adobe