Qt5 QMessageBox cannot tab between buttons - qt5

I have some code to bring up a QMessageBox, but when it prompts, I am unable to tab between the buttons. It is stuck on the default button.
Keys like Escape and Enter work just fine, but the Tab, Space and Left and Right keys do nothing. I would like to have it so pressing those keys will change focus from one button to another or if Space, will act as Enter.
I figured this would be default behaviour or simple to implement, but I'm not seeing it. I'd prefer not to a) build my own ui form, or b) build out a complex keyPressEvent function, but maybe that's what I'll be stuck with.
Using Qt 5.3.2, qt-creator 3.1.2 and 3.0.1 used, Mac OS X 10.6.8.
QMessageBox msgBox;
msgBox.setWindowTitle("This is a prompt");
msgBox.setIcon(QMessageBox::Question);
msgBox.layout()->setSizeConstraint(QLayout::SetMaximumSize);
msgBox.setText(tr("This is some text"));
msgBox.setInformativeText(tr("Here is some great information for you.\n"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
msgBox.setBaseSize(QSize(400, 160));
msgBox.setFocusPolicy(Qt::StrongFocus);
int ret = msgBox.exec();
I've tried using setFocusPolicy(Qt::StrongFocus);, but that has not helped.
I was able to get the desired effect from Qt 5.14.1 + qtcreator 4.10.1 on Linux, so I will do more testing. It may be specific to my platform.

Thanks to #VladimirBershov and the answer at https://stackoverflow.com/a/32378759/4149835 for helping me get through this.
Previously I had called setFocusPolicy(Qt::StrongFocus) on the message box object itself, but instead I do this:
QMessageBox msgBox;
msgBox.setWindowTitle("This is a prompt");
msgBox.setIcon(QMessageBox::Question);
msgBox.layout()->setSizeConstraint(QLayout::SetMaximumSize);
msgBox.setText(tr("This is some text"));
msgBox.setInformativeText(tr("Here is some great information for you.\n"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
msgBox.setBaseSize(QSize(400, 160));
QList<QAbstractButton *> bList = msgBox.buttons();
for (int i=0; i<bList.count(); i++)
{
bList.at(i)->setFocusPolicy(Qt::StrongFocus);
}
int ret = msgBox.exec();
And that fixes it! Mac OS X 10.6.8 requires strong focus policies on the buttons themselves to get this functionality.
EDIT
Setting focus policy to strong focus does work, but it's not the way that Mac OS X is intended to be used. I read a blog a while back that mentioned you need to go into:
System Settings -> Keyboard -> Keyboard Shortcuts tab
Then at the bottom, there should be a Full Keyboard Access section that gives you the ability to move keyboard tab focus between "Text boxes and lists only" (default), or "All controls". Setting to All Control means QT can use its default focus policy with OS X correctly.

Related

Krusader: using Alt+D as a shortcut

In Krusader, I want to use Alt-D as a shortcut to focus the location bar. This works fine for browsers and Dolphin. When I set the shortcut for "Go To Location Bar" to "Alt-D", setting the shortcut has no errors. When I try to use the shortcut, I get an error popup saying that the key sequence 'Alt+D' is ambiguous.
Note that I have to hit 'Alt+D' twice to get the error. This makes me think that I'm colliding with the 'Alt+D' consumed by Plasma.
What can I do to get Krusader to do what Dolphin, Firefox, and Chromium do?
It is not possible by now. This is known bug of Krusader. In Ubuntu 20.04 the same problem is reproducing.
In Krusader keys combination Alt + letter or digit is used to navigate through UI (menu items, buttons, tabs, navigation path items). So Alt + D is pointing to something in it.
There are many bug reports with the similar problem on Krusader bugtracker. May be one day this will be fixed. Links to the bugs:
Ambiguous shortcut (Alt + R)
cant use shortcuts (Alt+E) which conflict mnemonics
Alt+letter keyboard shortcuts conflict with accelerators
alt+letter shortcuts are overriden by main menu shortcuts
Alt-shortcuts dont work with secondary layout

Use HJKL in menus of JetBrains IDEs

Is it possible to use J and K when choosing a suggested auto-completion item? See the image below: I'd like to, maybe hold ALT or SHIFT (or in some other way differentiate between moving and typing), and use J and K to select the proper suggestion.
Is anything similar also available for moving around the menus (in Project view etc.)?
I was able to make this work by creating a shortcut ALT+J mapped to the Down key and ALT+K to the Up key.
You can move up and down in the popup without needing to move your hand away from HJKL to the arrow keys.
This also works in the Find in path window, though it does not work in the navigation menu.
Update: For Alt + K to work in the Find window since the version 2020+, one has to disable mnemonics in Settings, under Appearance & Behaviour -> Appearance -> Disable mnemonics in controls.
#Rok Povsic's solution is great and I used it a bit, but in some pop up menus like Intention actions, refactoring menu or usages the trick won't work.
So I used this Power Toys program from Microsoft to remap the Alt+J, Alt+K, Alt+H, Alt+L to arrow keys at windows level and now this works great everywhere around the IDE.
You can even specify only the app in which you want to override this shortcuts. For example for rider it will be "rider64.exe". You can find the name of the app you want to use in task manager under "Details".

Textexpander 5 optional section keyboard shortcut

I'm using TextExpander 5. Is it possible to use a keyboard instead of a mouse then working with a popup window with importing choices? Like, if I don't want to include a section I'd rather use my keyboard to uncheck a checkbox then reaching out for a mouse.
Thanks.
Actually completed such task by using Mac OS X built-in ability to TAB focusing on non-inputable UI elements.
You can change it at System Preferences > Keyboard > Shortcuts.
At a bottom of a window you will found «Full Keyboard Access». This guy will help you to do that I was hoping to get (and finally got).
If you are interested in following my adventures on this, go here https://forum.keyboardmaestro.com/t/is-there-a-way-to-count-how-many-times-a-key-was-pressed-since-boot/6618/15
tldr version of the link above;
Found somewhat "almost-there" solution. I can check current status of this option by typing in terminal:
defaults read -g AppleKeyboardUIMode
It will return 0 (off) or 2 (on) dependent of current setting.
Right now, I'm using Keyboard Maestro Macro for doing this.

IntelliJ-IDEA Eclipse Ctrl+O equivalent that is better than Alt+7

In Eclipse I could hit Ctrl+O and get a popup which I could use to get an overview of everything in the current class, pick an entry, and jump to it.
In idea, there is Alt+7, but I have a few issues with it. First, the keyboard doesn't seem to put its focus there. I have to take my hand off the keyboard and use the mouse to place the focus on the Structure dock.
I also don't like how it's taking up real estate. I don't want to change how things are laid out if I want to see the structure. I would like a more non-invasive popup, and handier and snappier.
Is there another feature that gives me quick access in the form of a popup preferably, like Ctrl+O provides in Eclipse?
Another nice feature would be to be able to use the J and K keys to move up and down the selection, instead of having to use the cursor keys. I'm using IdeaVim, so the normal workflow when editing files, is that both hands stay in a touch-type position. It would be nice if I can use the various navigation features also using vim keys...
Perhaps there is a way to enable this, that I haven't discovered yet?
IntelliJ equivalent of Eclipse's CTRL+O is CTRL+F12 (⌘+F12 on Mac), which will give you more or less the same pop-up as in Eclipse. But I'm not sure if it can be navigated using j and k keys.
More details can be found in the IntelliJ help.

Short cut in Xcode to switch between help and IDE

I'm new to the XCode IDE, Mac and IOS programming. Means that I'll swap a lot between help and editor. However when using Cmd+Tab I'll not swap between help and IDE but between other open apps.
Does anyone know a short cut to switch between IDE and help?
OPT+Cmd+? will bring the help in XCode (the shortcut is mentioned if you go to the help section)
use 1. in combination with CMD+' to scroll through all open projects / windows within XCode.
You can have a look to this page: it refers all XCode shortcuts and gesture.
The default shortcut to open the Organizer is Cmd+Shift+2, which you can edit in the Preferences of Xcode if you want.
There is also a shortcut which will directly bring you to the Documentation tab: Cmd+Alt+?.
Additionally, you can set a shortcut to switch between the windows of the active app in System Preferences → Keyboard → Keyboard Shortcuts. The default is Cmd+< but I prefer Alt+Tab.
Command-Option-Shift-/ (a.k.a. Command-Option-?) will bring up the documentation window.
Also, you can cycle between windows within an application with Command-` (works in any application). You can use that to switch easily between a project window and other open windows, including the documentation window.
Command-Tab cycles between applications, not windows.
Note that the keyboard shortcut for a given menu command will be displayed in the menu along with the command (this is true for any application):
If you are on Mountain Lion (not sure if it works on earlier versions), you can also use the 4 finger scroll (Mission Control shortcut) if you prefer. With the Organizer (help) open, use 4 fingers and swipe upwards to reveal mission control. On top you'll see virtual desktops. Drag and drop your Organizer/help window onto the second desktop. Now you can flick right or left with 4 fingers on your trackpad to switch between code view and help. I know this sounds complicated but once you get used to it, it becomes second nature. But yeah Cmd + ~ is good too.