Multiple shortcuts for one action in GTK - gtk

What is the best way to bind multiple keyboard shortcuts to one action in GTK+ 3?
I have been searching for an answer to this for a few days and have come up with naught. The function gtk_accelerator_parse does not support comma-deliminated shortcuts. Putting multiple <accelerator> tags in a .ui file with the same action attribute and different key attributes also does not work.
I do not want to have to write a custom key press handler just so I can have two shortcuts for one action, but is that really the only way?

Since GTK version 3.12 (released on 2014-03-25) there is a new method called gtk_application_set_accels_for_action() that should help.

I have found a way, but it is truly terrible. Using gtk_accel_group_connect I can add additional accelerators for my own functions which can then trigger the action desired based off the key pressed and any modifiers. This however feels like a hack as I am basically creating my own accelerator-to-action map rather than using GTK's.
I would like to know a better way, if anyone knows of one.

Related

Why aren't UIViewAnimationsOptions available in the drop down menu?

I'm working through the Code With Chris card matching game and when setting up the animation, he presses "." to bring up a list of options to select from. When I do the same thing my list of things to select from is different. I tried putting in the text manually but Xcode doesn't recognize it. What am I doing incorrectly?
Because the tutorial is calling UIView.animate but you are calling UIView.animateKeyFrames. Those are different methods and take a different set of options.
(There have also been some changes in the code completion interface since that tutorial was created.)

vscode extension onDidChangeCursorPosition

I am developing a vscode extention and I want provide something like the bracket match decoration. My problem is that I need to register onDidChangeCursorPosition and I don't know how to do that.
My purpose is to create a decorations that appears only when the cursor is on it.
There is no such event like onDidChangeCursorPosition. However you can use onDidChangeTextEditorSelection. The onDidChangeTextEditorSelection is actually a field on the vscode's window object and you can assign your own function to it which gets called when this event is sent. Look at my extension (or many others which do that) to learn how to handle the cursor change event.

How can I use mnemonics on JavaFX 8 Alerts

I would like to be able to add accelerator keys for the buttons that are provided as a part of the Alert Dialog Controls included with JavaFX.
I am unsure if this is possible using the standard alert types ERROR, INFORMATION, CONFIRMATION, WARNING?
I created my own login window - which doesn't use an Alert structure and it works as follows:
When the stage opens up.
Then when the user hits the "ALT" key:
I would like the ability to "Hot Key" the buttons on the Alerts in the system. However, I am unsure if I can use the standard alerts, or if I need to create my own, and if so, how should I do that.
I really would like to use the Dialogs natively, if at all possible.
Thanks.
As far as I understood your question, I think it isn't possible without some extra code.
Looking at the code of OpenJFX the labels of the buttons are localized and fixed.
You might just want to create some buttons on your own by using the apropiate constructor which takes some buttons where you can override the existing ones.
EDIT: after rethinking everything, I tried to recreate your problem. You can see that project on GitHub..
This is the special code:
public void showCustomizedAlertWindow() {
Alert a = new Alert(AlertType.CONFIRMATION, "some content text", ButtonType.OK, ButtonType.CANCEL, ButtonType.FINISH);
((Button) a.getDialogPane().lookupButton(ButtonType.FINISH)).setText("_finished");
a.show();
}
But be aware, you are removing localization-support of that buttons.

What would be the best approach to implement a multi-select combo in SWT/JFace?

I need to implement a multi-select combobox using SWT/JFace, What would be the best approach?should i go for changing the source code or i should try to extend the combo?
It is not possible to extend a Combo It is possible to extend Combo by overriding checkSubclass(), however it is highly disapproved of. The alternative is to create a wrapper for it. But that would be too much work.
Extending a CCombo is an option, but not a very good idea. Again, too much work for the functionality you need.
BUT
As sambi reddy mentioned, you could use a TableComboViewer from Nebula (scroll down to "TableCombo").
Another convenient solution (my favorite) is to have a CheckboxTreeViewer since you need to implement multi selection and such.
screenshot
https://github.com/lawhcd/SWTMultiCheckSelectionCombo
For anyone who is looking for a widget that allows user to select multiple options from a list of check box style options.
It is based on user1438038's idea and extended to provide nearly all of the api required of a widget similar to Combo.

How to programmatically change help contents in Eclipse?

I have an eclipse plugin and I would like to programmatically disable help content TOC's based on a variable I define. In a nut shell, I want to prevent some help docs from showing up in the help contents if a specific type of user is accessing the plugin.
Preferably I would like to do this in the ApplicationWorkbenchAdvisor somewhere.
One thought would be to modify the "primary" value to be false if the variable were set.
Not sure if it would work, but try using the org.eclipse.ui.activities extension point. The tutorial from Vogella tells it is possible to hide only UI elements like wizards, views and so on, but it is from 2009.. Not sure if hiding TOC is now possible. If you try it out, would be nice to give a feedback ;)