Skip to content

Add toggleMenuBarOnAltPressed option to BrowserWindow. - #3218

Closed
danhper wants to merge 1 commit into
electron:masterfrom
danhper:master
Closed

danhper wants to merge 1 commit into
electron:masterfrom
danhper:master

Conversation

@danhper

@danhper danhper commented Oct 26, 2015

Copy link
Copy Markdown

Hi,

I recently started using Atom and had some issues with the Alt key
toggling menu bar, so I added an option to disable this behavior.

The option can be passed when instanciating a BrowserWindow,
or be changed using the setToggleMenuBarOnAltPressedmethod
on a BrowserWindow instance.
I also added a doesToggleMenuBarOnAltPressed method
to retrieve the current value of the option.
The option is disabled by default, so this will not break or change the behavior of
existing apps.

Background

In some apps, such as Atom, the menu bar can be restored in other ways,
and as it is not something that is done so often (at least for my usage),
I think this option makes sense.

I will explain my issue in Atom, which is my actual motivation for this option.
I use XMonad, and my shortcut to change window focus is alt+j.
When I press alt, menu_bar_alt_pressed becomes true.
Then, when I press j, the keydown event is intercepted by XMonad,
and the focus changes to some other app, let's say my browser.
As Atom did not receive the j keydown event, menu_bar_alt_pressed is still true.
When I then want to go back go Atom, I press alt+j again. I usually release the
j button instantly, and the alt after, so the j keyup is not handled by atom, but
the alt keyup event is, which makes the condition for toggling the menu bar true.
So basically each time I change focus to some other app and go back to Atom,
the menu bar is toggled, which is a little annoying.

The option can be passed as an option when instanciating
a `BrowserWindow`, or be changed using the `setToggleMenuBarOnAltPressed`,
method on a `BrowserWindow` instance.
@zcbenz

zcbenz commented Oct 26, 2015

Copy link
Copy Markdown
Contributor

Why not just disables the auto-hide menu?

@danhper

danhper commented Oct 26, 2015

Copy link
Copy Markdown
Author

@zcbenz I want the menu to be always hidden, not always shown.
Is there a way to disable auto-hide menu and keep the menu hidden?

@zcbenz

zcbenz commented Oct 26, 2015

Copy link
Copy Markdown
Contributor

@tuvistavie There is setMenuBarVisibility API to show/hide the menu.

@danhper

danhper commented Oct 26, 2015

Copy link
Copy Markdown
Author

@zcbenz Great, that's perfect! Thank you.

@danhper danhper closed this Oct 26, 2015
@theFroh

theFroh commented Oct 30, 2015

Copy link
Copy Markdown

Does using setMenuBarVisibility to disable the menu appearing prevent the menu taking focus as well?

@danhper

danhper commented Oct 30, 2015

Copy link
Copy Markdown
Author

@theFroh It does not seem to. If I press alt+e (at least in Atom), the edit menu and the menu bar shows up even with setMenuBarVisibility set to false. However, if the shortcut is assigned, the assigned binding takes advantage.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants