Skip to content
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

Menu bar visibility toggling when it should't #35010

Closed
jwarkentin opened this issue Sep 26, 2017 · 19 comments
Closed

Menu bar visibility toggling when it should't #35010

jwarkentin opened this issue Sep 26, 2017 · 19 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@jwarkentin
Copy link

I'm running on a Linux environment using Gnome. I have the window.menuBarVisibility setting set to toggle which is triggered with the Alt key. Unfortunately, when I switch desktops using the default keyboard shortcut of Ctrl+Alt+[arrow], VSCode seems to think I've pressed Alt and it toggles the menu bar every time which is really annoying.

I tried changing the keyboard shortcut to Alt+M to toggle visibility but VSCode seems to still make it also toggle with Alt no matter what shortcut I set. The shortcut I configure just becomes an additional way to toggle it. I then tried setting the menu bar visibility to hidden hoping that would disable Alt so it would only toggle with my configured shortcut but once I press my configured toggle shortcut VSCode will go and change my setting from hidden back to toggle thus re-enabling the Alt shortcut to toggle.

There needs to be a way to either disable/change the Alt menu toggle shortcut or at the very least not trigger it when I switch desktops holding Ctrl+Alt+[arrow].

@vscodebot vscodebot bot added the workbench label Sep 26, 2017
@sandy081
Copy link
Member

I tried changing the keyboard shortcut to Alt+M to toggle visibility but VSCode seems to still make it also toggle with Alt no matter what shortcut I set.

Can you please open your keybindings.json file and check what keybindings are attached to the window.menuBarVisibility command?

@sandy081 sandy081 added the info-needed Issue requires more information from poster label Sep 26, 2017
@alexdima alexdima assigned bpasero and unassigned alexdima Sep 26, 2017
@alexdima
Copy link
Member

This might be an Electron limitation. @sandy081 We don't do anything special on Alt on our side. i.e. we don't ship with any keybindings mapped to alt.

@bpasero bpasero added this to the Backlog milestone Sep 26, 2017
@bpasero bpasero added the linux Issues with VS Code on Linux label Sep 26, 2017
@jwarkentin
Copy link
Author

@sandy081 There is nothing set for that in my keybindings.json file. Apps commonly use Alt to toggle menu visibility. This might be built into Electron. The problem is that it also toggles visibility if I press Ctrl+Alt (regardless of whether I end up hitting an arrow key). Maybe there's a way to capture Ctrl+Alt explicitly and make it do nothing?

@jwarkentin
Copy link
Author

jwarkentin commented Sep 26, 2017

Just messed around with it more and it's really weird. Apparently if I press Ctrl+Alt in that order then it will toggle the menu bar. However, if I press Alt+Ctrl in that order then it doesn't toggle it.

@akbyrd
Copy link
Contributor

akbyrd commented Oct 26, 2017

This affects Windows as well. The core issue is that Alt toggles the menu when it is pressed as part of some other key combination in certain cases.

Scenario 1: hold Ctrl, press and release Alt
Result: Menu bar is toggled

Scenario 2: hold Alt, press and release Ctrl, release Alt
Result: Menu bar is not toggled

Ctrl can be replaced with any other key in both scenarios.

The expected behavior in both cases is that the menu bar is not toggled.

What I suspect is going on is that if another key is pressed while Alt is being held then releasing alt will not toggle the menu bar, but if another key is already held down while Alt is pressed and released then releasing Alt will toggle the menu bar. The specific change I'm supporting is that pressing and releasing Alt while another key is held should not cause the menu bar to be toggled.

I intended to open an issue for this as the inconsistency seems to be a bug. It's a constant annoyance in my daily work with VS Code. I use Ctrl+Alt+Left/Right to move focus between groups and if Alt bounces an extra time it toggles the menu bar. I also use different combinations of modifier keys and Left/Right for various editor group related actions so when I'm thinking about my next action I may press Ctrl+Alt then change my mind and release Alt. It happens too when I'm working quickly and I accidentally hit Alt a split second after theIt's an unwanted distraction to say the least.

@jwarkentin
Copy link
Author

So it sounds like this is a more fundamental issue with whatever is handling keyboard event bindings in general. If I have an event bound to Alt then my handler should only fire when that is the only key pressed. Whatever is in charge of firing keyboard event bindings right now must not be checking for exclusivity of the bound key combination before firing handlers.

@bpasero bpasero added bug Issue identified by VS Code Team member as probable bug workbench-menu and removed info-needed Issue requires more information from poster workbench labels Nov 15, 2017
@bpasero bpasero removed this from the Backlog milestone Nov 16, 2017
@akbyrd
Copy link
Contributor

akbyrd commented Nov 17, 2017

I noticed another aspect of this issue today: Escape does not close the menu bar.

Steps to reproduce

  1. Press Alt+H to open the Help menu (which shows the menu bar as a side effect).
  2. Press Escape.
  3. Notice the Help menu closes, but the menu bar remains visible.

Expected behavior
When pressing Escape the menu bar should be hidden.

The expected behavior is supported by the fact that when I press Alt+H to open the Help menu, highlight something, and press Enter the menu bar will be hidden.

@akbyrd
Copy link
Contributor

akbyrd commented Nov 17, 2017

@bpasero I don't think the linux label is appropriate here, as this affects Windows in addition to Linux.

@bpasero bpasero removed the linux Issues with VS Code on Linux label Nov 18, 2017
@lyallh
Copy link

lyallh commented Mar 7, 2018

I am in the exact situation this issue describes. I want to change the toggle key from Alt to Alt+M to stop annoying incedental alt menubar toggles.

As already stated, the root of this issue in this case is that, to hide the menubar, workbench.action.toggleMenuBar changes the window.menuBarVisibility setting to toggle, when instead it needs to return it to my original hidden setting.

Can toggleMenuBar be implemented in a way that preserves the user's menuBarVisibility setting?

What's confusing things is toggleMenuBar seems to be trying to implement a toggling system on top of the built in Alt system while still preserving that built in behaviour. So there's lots of cases to think through.

If there's no good reason for this can we not just have the default toggleMenuBar key set to Alt and have toggleMenuBar toggle menuBarVisibility between default and hidden (instead of default and toggle)

If there's reasons against that, can the toggleMenuBar behaviour depend on whether a keybinding is set or not? Then (at least until Electron's apparently buggy built-in Alt toggle behaviour is fixed) I'd propose:

If there is no key set for toggleMenuBar then the behaviour as currently implemented is fine.

However, If a user has explicity set a keybinding to toggleMenuBar then that should override the built-in Alt toggle, since that's obviously the user's intention by setting their own key. So toggleMenuBar should change behaviour and toggle between default and hidden.

@lyallh
Copy link

lyallh commented Mar 9, 2018

@bpasero the fix in electron has been approved.

FWIW I still think if a toggleMenuBar shortcut key is set it should override the default Alt behavior but should be a non issue now. I might PR if you agree

@jwarkentin
Copy link
Author

I'm excited to finally have a solution to the main annoyance. There are obviously still a few improvements that should be made as explained by @lyallh but this is good stuff! The question now is, when will we see this electron fix in a VSCode release?

@lyallh
Copy link

lyallh commented Mar 19, 2018

@jwarkentin Happy to report that my fix was included in the recent electron 2.0.0-beta.4 release which is used now in the tyriar/electron-2.0.x vscode branch.

I just built and ran the branch and can confirm the menu bar is no longer "toggling when it shouldn't".
Hurrah.

@bpasero may have some idea of when this branch might make it into a release...

Edit: Upgrade to electron 2.0.x is a March 2018 milesone. Follow #45542 for builds!

@bpasero bpasero added this to the April 2018 milestone Mar 24, 2018
@bpasero
Copy link
Member

bpasero commented Apr 3, 2018

Closing as the update to Electron 2.0.0-beta.6 landed via 88603b3. It should be in insider releases end of this week.

@bpasero bpasero closed this as completed Apr 3, 2018
@bpasero bpasero reopened this Apr 6, 2018
@bpasero
Copy link
Member

bpasero commented Apr 6, 2018

Reopening as we had to revert the update.

@bpasero
Copy link
Member

bpasero commented Aug 6, 2018

Closing, we pushed the Electron 2.0.x update for July release.

@chrmarti chrmarti added the verified Verification succeeded label Aug 6, 2018
@chrmarti
Copy link
Collaborator

chrmarti commented Aug 6, 2018

Verified on Windows and Linux.

@akbyrd
Copy link
Contributor

akbyrd commented Sep 8, 2018

@bpasero There are still two issues with this:

  1. Hold Ctrl, press and release Alt, notice the menu bar is toggled.
    I've tested with various other applications on WIndows including Notepad, Paint, and Firefox. None of theme do this.

  2. Press and release Alt, press escapse, notice the menu bar does not get hidden.
    I tested with Firefox and Visual Studio 2015 (using https://marketplace.visualstudio.com/items?itemName=MatthewJohnsonMSFT.HideMainMenu) and both will hide the menu bar when escape is pressed.

As I mentioned earlier in the thread, issue 1 is a daily annoyance for me, as it seems to happen very frequently when I jump between editor groups.

The new menu bar doesn't have these issues and it feels like the menu bars should be consistent with each other and with the rest of the Windows experience.

@pkieltyka
Copy link

@akbyrd same issue for me, I ended up setting the toggle to "hidden", which means it never toggles and I can't use it at all. However, ctrl+shift+P allows me to call up any command I really need, luckily

@akbyrd
Copy link
Contributor

akbyrd commented Sep 10, 2018

I've split the remaining bugs out into new issues.

#58376
#58377

@vscodebot vscodebot bot locked and limited conversation to collaborators Sep 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

8 participants