Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Menu keeps stealing the focus when I hotkey into Foobar (Read 1639 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Menu keeps stealing the focus when I hotkey into Foobar

I'm having a very annoying issue with Foobar. I have set a hotkey for the "Activate" command but quite often, when the window is shown, the MENU (File, etc) is automatically focused, which is a big problem for me because I can't use hotkeys. I have the focus on the "File" menu button and no hotkeys work while the focus is stolen inside that component.

For now, the only fix I found was to create a GLOBAL hotkey that focuses the currently playing song in the playlist. But pressing two hotkeys to show the player is cumbersome at best.

Does anybody have any idea about a way to solve this? I'm using Columns UI and I have stripped almost everything from the interface. I just have a playlist and the toolbar.

I tried lots of ways to fix this.

- I tried to hide the toolbar completely and add the menu as a component in a splitter.
- I tried to auto-hide the menu, but it still steals the focus.
- I tried adding the seek bar at the start (left) and the menu far to the right.

Nothing works :(

This issue happens when I ALT + TAB out of Foobar and then use my hotkey to bring it to front.

Re: Menu keeps stealing the focus when I hotkey into Foobar

Reply #1
What is the keyboard shortcut you're using to activate foobar2000? And is it a foobar2000 command or another program?
.

Re: Menu keeps stealing the focus when I hotkey into Foobar

Reply #2
Thanks for answering :).

Using CTRL + ALT + X and it's Foobar's own "View / Activate" shortcut, set as global hotkey. I also have another program called Hotkeyz. Same situation with both alternatives :(.

Re: Menu keeps stealing the focus when I hotkey into Foobar

Reply #3
[edit] OK, I reproduced it here. Will have a look at what is going on...

As a workaround, it doesn't seem to happen with a keyboard shortcut that doesn't use Alt. (I use Win+\ to close foobar2000 – \ being next to left Shift on my keyboard.)

[second edit] It doesn't seem to be a Columns UI bug - the window gets a message saying the menu key was pressed. It happens with Default UI too here and only seems to happen if Alt is released before Ctrl and X (and you had alt-tabbed out of foobar2000 before that).

I don't see any immediate way to fix it so my best advice would be to use a different keyboard shortcut.
.

Re: Menu keeps stealing the focus when I hotkey into Foobar

Reply #4
The fact that the ALT key is a problem is not surprising because ALT is the "menu key" in Windows. You're right that it also happens in the non-Columns UI interface, but there's one BIG, HUGE DIFFERENCE:

In the Default UI, keyboard shortcuts still work even though the menu has the focus ;). Which is probably why I haven't noticed that until this week, when I upgraded my Foobar and invested hours into an UI overhaul. This thing with the Default UI means that there might be a quick fix for this issue. I'm suspecting that there's a simple line of code somewhere which sets up hotkey forwarding :). Some message forwarding in the WindowProc or something like that.

I really like CTRL + ALT, it's comfortable to press... WinKey + X might work, but...

Until there is a fix, I guess my only option is to remove the menu completely. I realized that I don't use the menu too much anyway :). I got hotkeys for pretty much everything so... bye bye menu for now :D.

Thank you for going through the effort to reproduce and analyze the problem!

Re: Menu keeps stealing the focus when I hotkey into Foobar

Reply #5
They work in the Default UI if the menu is focused, yes, but not if one of the menus is open. Normally, if you activate the menu via the keyboard, it's to use it, and I vaguely recall things like P being assigned to Preferences at some point in the past (which interfered with activating individual menus). So, it was intentional (and I think it's fair to consider the menu bar as the top-level of the hierarchy - remember some apps don't use a menu bar and just use a popup menu from the corner of the window instead).

I'm not convinced either way about whether it should be changed: for all I know someone might be reliant on the current behaviour. I checked a few programs, and none of IE, Firefox and Notepad responded to Ctrl+P when the menu was activated.

Also note that Esc and Alt both deactivate the menu (F10 is meant to as well, but apparently I have a bug there).
.

Re: Menu keeps stealing the focus when I hotkey into Foobar

Reply #6
Thank you for giving time and thought to this issue. I am pleasantly surprised to see this level of interaction from you. Are you one of Foobar's developers?

You're half right with the ESC & ALT keys :). They do deactivate it if you activated it "by intent". However, in my case, the problem happens when I ALT+TAB out of Foobar. In this case, when coming BACK to Foobar, the menu is activated but neither ESC nor ALT work to de-activate it :(. Pressing ALT just re-activates it perpetually and pressing ESC does nothing...

As a developer myself, I believe that it would be consistent behavior to deactivate the menu on tabbing-out of Foobar. At least this could be added as an advanced option in the program and would fix the issue in what I believe to be an elegant way. Alternatively, an advanced option that would restore old-menu behavior: forwarding hotkeys to the application would be an alternative.

Even though I can't really ask of anybody to code this, I think the current behavior could be improved. Priority-wise, it's obviously low :). I don't miss the menu so much now that I removed it :D. So I can live with this.

Re: Menu keeps stealing the focus when I hotkey into Foobar

Reply #7
Nope, I wrote Columns UI :)

Esc and Alt do deactivate the menu here even if the menu was activated through this bug, so not immediately sure why you are seeing something different.

I do agree that if the menu is active on Alt-Tab it should be automatically deactivated. But, this is an additional problem, right? (Aside: you might have some sympathy if you have a read about how the whole thing was implemented many years ago...)

Anyway, I think I have a simple workaround: don't activate the menu if Ctrl is down. I can't think of a scenario when the menu should be activated when Ctrl is down.
.

Re: Menu keeps stealing the focus when I hotkey into Foobar

Reply #8
Well well, pleased to meet you then! :). Great work!!! How does one donate to you?

Interesting. I see now why there is a difference in behavior. Seems like quite a departure from the standard control. Lots of low level API calls to control behavior there.

Perhaps I did not explain well enough how to reproduce the situation when ESC/ALT do not deactivate the menu. Here's an easier method: press ALT to activate the menu. Then, use your mouse to go into another window on your task bar. Now, ALT + TAB back to Foobar. The menu is still activated. Pressing ESC/ALT does not deactivate it (ESC does nothing while ALT re-activates it at every press, instead of toggling it).

I don't see how the CTRL workaround would work? You mean that when pressing CTRL you would de-activate the menu and thus allow keyboard shortcuts to be used by the program?

Re: Menu keeps stealing the focus when I hotkey into Foobar

Reply #9
Well well, pleased to meet you then! :). Great work!!! How does one donate to you?
I used to have a donate button on my website, but I took it off at some point :)

Interesting. I see now why there is a difference in behavior. Seems like quite a departure from the standard control. Lots of low level API calls to control behavior there.
Yes, and the fact it is a panel further complicates things. Also, the behaviour was modelled on Windows Explorer in either Windows XP or Vista – but those themselves did not behave entirely correctly.

Perhaps I did not explain well enough how to reproduce the situation when ESC/ALT do not deactivate the menu. Here's an easier method: press ALT to activate the menu. Then, use your mouse to go into another window on your task bar. Now, ALT + TAB back to Foobar. The menu is still activated. Pressing ESC/ALT does not deactivate it (ESC does nothing while ALT re-activates it at every press, instead of toggling it).
Ah, yes you are right. I will look into that at some point.

I don't see how the CTRL workaround would work? You mean that when pressing CTRL you would de-activate the menu and thus allow keyboard shortcuts to be used by the program?
It works, I've checked :) The menu is activated in response to a window message the main window receives. Because the bug only triggers when Alt is released before Ctrl and X, I can check if Ctrl is down at that point. Of course, that only works for keyboard shortcuts with Ctrl in them, but I'm not sure what other combination one would use.

BTW you can trigger the bug in other programs that normally only allow a single instance to run, using only OS features. Set a keyboard shortcut with Alt in it in the properties of a shortcut to such a program (Notepad++ is one such program). Follow the same steps i.e. run that program, Alt-Tab out of it, press the keyboard shortcut (hold it down until the program window is activated) and then release Alt. End result: the main menu is focused. So, if there was any doubt, it is an OS bug.
.

Re: Menu keeps stealing the focus when I hotkey into Foobar

Reply #10
So then give me  your PayPay e-mail so I can donate something for your great work.

Yes, I the CTRL thing might work to fix some situations, but not ALT + TAB.

Regarding OS bugs, let me tell you an "inspiring" story :D. About 12 years ago I started developing a systray clock replacement called ASD Clock (it's open source now). In the process, I found an OS bug: if you would resize the taskbar, Windows would mess up the sizing of the systray window. It happened also when I wasn't hooked into explorer.exe. I was like... "challenge accepted!" :D. I fixed the OS bug through a workaround: I used a timer that was checking if the size was ok a few milliseconds after each resize. If it found that the size is wrong, I sent some fake "WM_RESIZE" messages. It felt great to fix one of Microsoft's bugs :D.

Re: Menu keeps stealing the focus when I hotkey into Foobar

Reply #11
Columns UI 0.4.0 RC 1 should help with the Ctrl+Alt+X problem.

I haven't put a fix in yet for not deactivating the menu when the main window is deactivated; that one's a bit more involved and may need Panel API changes/extensions.
.