New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isVisible() to app.dock #6683

Merged
merged 1 commit into from Aug 2, 2016

Conversation

Projects
None yet
2 participants
@gabriel
Contributor

gabriel commented Aug 1, 2016

It would be nice to be able to know if the dock is visible or not. The dock is a little quirky though and since app.dock.show isn't synchronous, the isVisible may not be true immediately after show. But I think if we mention that in the docs, people would be wary of that?

Or we could add an instance var to track whether the dock is in the process of showing?

I tested this in the electron-quick-start app with:

setInterval(function(){
  console.log('dock visible:', app.dock.isVisible())
  if (app.dock.isVisible()) {
    app.dock.hide()
    console.log('after hide:', app.dock.isVisible())
    console.log('-')
  } else {
    app.dock.show()
    console.log('after show:', app.dock.isVisible())
    setTimeout(function(){
      console.log('after show (with delay):', app.dock.isVisible())
      console.log('-')
    }, 10);
  }
}, 1000)

The output of this looks like:

dock visible: true
after hide: false
-
dock visible: false
after show: false
after show (with delay): true
-
dock visible: true
after hide: false
-
dock visible: false
after show: false
after show (with delay): true
...

I wasn't sure if there was a test suite to add to or if this type of testing was manual. I can push my test app branch if you would like to try it out.

@zcbenz

This comment has been minimized.

Contributor

zcbenz commented Aug 2, 2016

👍

Or we could add an instance var to track whether the dock is in the process of showing?

A more Electron way is to add a callback to dock.show, but I think we don't have to do it now until someone really needs it.

@zcbenz zcbenz merged commit 7ac28b5 into electron:master Aug 2, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@gabriel

This comment has been minimized.

Contributor

gabriel commented Aug 2, 2016

I could also see maybe app.dock.on('show', ...) and app.dock.on('hide', ...) being useful.

@zcbenz

This comment has been minimized.

Contributor

zcbenz commented Aug 3, 2016

Adding show/hide events for dock might be a good idea, these events only happen when you call dock.show/hide(), anyone who needs can just put a hook before the API calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment