pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

alt-key menu bar focus interference

Open wlwl2 opened this issue 3 years ago • 11 comments

Have you checked for existing feature requests?

  • [X] Completed

Summary

I'm bringing an issue that Electron had into here (for a long time) to track its development. https://github.com/electron/electron/issues/34211#issue-1234548094

I'm not sure about this but I read somewhere that Pulsar was open to allowing the menu bar to be hacked (and therefore every part of the editor)? This would then be covered when that is considered as well.

Enter your response below:

Many people are having this issue, there were about 5 or 6 issues that I saw over multiple repos Electron, Atom. These ranged from language switching issues because of this new feature, important keyboard shortcuts causing issues, and just pressing the alt-key alone causing the menu bar to be focused accidently.

Any alternatives?

VSCode has settings to adjust this, but Atom doesn't. Not sure about Pulsar. See the last comment on the issue referenced.

Other examples:

This was a new update at some point causing the problem with Electron. VSCode has settings to adjust this.

wlwl2 avatar Oct 23 '22 13:10 wlwl2

Sorry there was never an original response on this issue. But thanks a ton for reporting it!

Looking at the linked issue, it seems it has never been addressed by Electron maintainers and is still open. Meaning we have only a single way to change it, (which is the same way VSCode does) and that's to not use a native title bar at all.

Which that is a whole other complication into matters, but has been discussed other places as a potential solution, so there may be a lot of validity into pursuing this more, such as #442 and #345

confused-Techie avatar May 21 '23 01:05 confused-Techie

So, if anyone wants to implement this, here are some guidelines:

All menus are defined natively in Electron, on the Main Process, at this file: src/main-process/application-menu.js

It's called via an IPC message called 'update-application-menu', defined at line 877 of src/main-process/atom-application.js. Finally, it is exposed as an API to the renderer process at src/menu-manager.js.

So, it's not that hard to fix - you just will need to make a "pure CSS + HTML" menu, and then instead of calling the IPC message, just update the UI with the relevant "new menu". The "good news" is that the IPC message always sends the full menu - meaning that you won't need to do any "diff" or whatever other stuff, you can literally destroy and reconstruct everything, everytime, and it'll work - here's an example on how the menu structure is sent via the IPC message:

image

Hopefully that helps :)


UPDATE: remember that menus can have keystrokes, so you'll probably need to add them at the keymaps too, and remove them when the menu is invalidated.

mauricioszabo avatar Sep 29 '23 17:09 mauricioszabo

the easiest workaround is set new keymap for pure alt with any random text... like:

'*':
  'alt': 'miss'

An option in setting to inject this chunk into keymap will make it easier for users

asiloisad avatar Sep 29 '23 21:09 asiloisad

I'd like to thank all-involved for continuing this project and I'm sorry for being dramatic but this issue is literally preventing me from using the package as I use alt frequently while typing as many-others do going-by the original issue linked to at the OP. Would it be possible to add an option don't show hidden-menu when Alt is pressed or similar that implements this apparently easy-fix? https://github.com/electron/electron/issues/34211#issuecomment-1731639104

tukkek avatar Sep 05 '25 18:09 tukkek

I'd like to thank all-involved for continuing this project and I'm sorry for being dramatic but this issue is literally preventing me from using the package as I use alt frequently while typing as many-others do going-by the original issue linked to at the OP. Would it be possible to add an option don't show hidden-menu when Alt is pressed or similar that implements this apparently easy-fix? electron/electron#34211 (comment)

If it's truly that simple, you might be able to put that exact code into your init file and reload/relaunch Pulsar.

savetheclocktower avatar Sep 05 '25 19:09 savetheclocktower

I have wrote an solutions 2 years ago, I'm using it till today and do not see any drawback. You reacted with negative review about it, but what is the reason?

asiloisad avatar Sep 05 '25 20:09 asiloisad

Neither of the solutions work, sorry. I've obviously tried them.

tukkek avatar Sep 05 '25 21:09 tukkek

Neither of the solutions work, sorry. I've obviously tried them.

I know you're at your wit's end, but imagine for a moment that your experience is an outlier, and that the meanings of your emoji reactions might not be as obvious to others as they are to you. We'll figure this out.

Let's try this — paste this exact code into your init.js, replacing whatever you added before:

window.addEventListener("keydown", (e) => {
  console.log('TEST 1');
  if (e.altKey) {
    console.log('TEST 2');
    e.preventDefault();
  }
}, { capture: true });

The { capture: true } ensures we get to act on the event in an earlier before anything else may stop its propagation. And the console.log makes it so that you can open the developer tools and look at the console to see if the listener is working — if you don't see TEST in your console when you press the Alt key, it isn't.

After you put that in, save it, and reload your window or relaunch Pulsar. If that fails to stop the menu from opening, open your dev tools and tell us whether you see TEST 1 and TEST 2 in your console, or one but not the other.

savetheclocktower avatar Sep 05 '25 21:09 savetheclocktower

I know you're at your wit's end

What's with the attitude in these replies? I'm here trying to get help while giving your application a honest-to-god first-try, not to be harassed in every reply.

Anyway, I'm moving on and unsubscribing to this. Best of luck to y'all. VS Code doesn't have this issue any-more even if it did at one point. Hope y'all figure it out.

tukkek avatar Sep 05 '25 22:09 tukkek

What's with the attitude in these replies? I'm here trying to get help while giving your application a honest-to-god first-try, not to be harassed in every reply.

Anyway, I'm moving on and unsubscribing to this. Best of luck to y'all. VS Code doesn't have this issue any-more even if it did at one point. Hope y'all figure it out.

People on GitHub are often communicating in situations where some folks aren't native English speakers. I don't think anyone is trying to harass you, and I'm certainly not trying to give you attitude. I'm just trying to steer clear of any misunderstandings.

I sensed a tone of exasperation in your requests — as though you had been suffering from this issue for a long time while using Pulsar, not as someone who was just trying out Pulsar and had a feature request. If I got that wrong, that's fine. I'd still like you to try the fix I proposed, since I was able to get that handler to trigger when the first one didn't.

savetheclocktower avatar Sep 05 '25 22:09 savetheclocktower

Two solution has been provided, but you reject them without any comments what is wrong with them. I'm glad you're aware of "being dramatic" lol

asiloisad avatar Sep 06 '25 02:09 asiloisad