A Javadoc from MMenuElement says:
String org.eclipse.e4.ui.model.application.ui.menu.MMenuElement.getMnemonics()
Returns the value of the 'Mnemonics' attribute.
If the meaning of the 'Mnemonics' attribute isn't clear, there really should be more of a description here...
Returns:
the value of the 'Mnemonics' attribute.
I strongly suspect, that Mnemonics attribute has something to do with hot-key shortcuts, like in Swing or AWT. But still, it is not quite clear, how to use them on Eclipse4 platform correctly. For example, how to assign Alt+F to a "File" menu item?
Can anyone provide me with a clue, example or HOWTO on this topic?
This is only the default javadoc as set by the EMF generator. So there was no real documentation done up to now.
You're right, mnemnoics got to do with shortcuts, but not the way you describe it. You are talking about key bindings, mnemonics are this:
&Open leads to a menu text with an underlined O which indicates keyboard accessibility. This shows to the user that the command is reachable using the platform specific accelerator. It is however platform dependent on how you see them, on OS X for example the accelerator is shown next to the label and hence has no effect.
see the javadoc of org.eclipse.swt.widgets.MenuItem.setText(String string) for a detailed explanation. The e4 model simply results in this call on the element, which happens in org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem:499
OS X information Mnemonics are not shown on Mac by definition, see Java Development Guide for OS X for the design definition.
Related
The question:
In Swing, when my MouseWheelListener receives a MouseWheelEvent, how can I combine the multitude of parameters contained within that event to obtain a single signed integer representing the number of units to scroll by, taking into account the fact that the "event type" may be either MouseWheelEvent.WHEEL_UNIT_SCROLL or MouseWheelEvent.WHEEL_BLOCK_SCROLL ?
Background:
Anyone who has ever had to deal with Swing's MouseWheelEvent must have noticed that it is preposterously complicated: instead of a single parameter containing the amount by which to scroll, it offers 5 parameters: getScrollType(), getScrollAmount(), getWheelRotation(), getPreciseWheelRotation(), and getUnitsToScroll().
The "scroll type" appears to be crucial for this, however the documentation (Which nowadays can be found at Oracle - Class MouseWheelEvent) mentions but does not explain the value of WHEEL_BLOCK_SCROLL.
Adding insult to injury, Oracle's own "tutorial" on the mouse wheel listener Oracle: How to Write a Mouse-Wheel Listener completely fails to show what to do when WHEEL_BLOCK_SCROLL is received, and instead shows how to display "WHEEL_BLOCK_SCROLL" when that happens.
It appears that WHEEL_BLOCK_SCROLL is very seldom implemented, so it is quite unclear how to handle it, and how to even observe it happening. One of the very rare pieces
of code that you can find out there which attempts to do something meaningful with WHEEL_BLOCK_SCROLL is at Github / iconfinder / batik / sources / org / apache / batik / swing / JSVGScrollPane.java but the code is commented-out, so I cannot trust that it ever worked.
Perhaps events of type WHEEL_BLOCK_SCROLL can be triggered if you go to "Mouse" settings in Windows, and in the "Roll the mouse wheel to scroll" box select "One screen at a time" instead of "Multiple lines at a time", but I have not tried this yet. Here is an unanswered question about this on stackoverflow: How do I generate a java swing WHEEL_BLOCK_SCROLL event?
Just by looking at the documentation, and not having worked with MouseWheelEvents in practice, I suspect that the method getUnitsToScroll() performs exactly what you are asking for.
The documentation says:
This is a convenience method to aid in the implementation of the common-case MouseWheelListener - to scroll a ScrollPane or JScrollPane by an amount which conforms to the platform settings. (Note, however, that ScrollPane and JScrollPane already have this functionality built in.)
This method returns the number of units to scroll when scroll type is MouseWheelEvent.WHEEL_UNIT_SCROLL, and should only be called if getScrollType returns MouseWheelEvent.WHEEL_UNIT_SCROLL.
In case you hit a WHEEL_BLOCK_SCROLL, probably the page-up or page-down keys were pressed. In that case the amount to scroll is one page size, resembling the component's getHeight() value.
When using a screenreader, like NVDA, I want to be able to hear the text of the menu when I hover my mouse over it. I am able to hear the text when I push the buttons in the menubar, but not when I hover over them (the screenreader does reads the menu's of other programs when only hovering over the buttons).
I have set the AccessibleContext like below:
JMenu.getAccessibleContext().setAccessibleName("text");
JMenu.getAccessibleContext().setAccessibleDescription("more text");
I can set listeners to the objects that detects when a mouse hovers over them, but I do not know if/how I can cast a text to the screenreader to read. I tried ToolTipText, but that text is not read by the screenreader either. RequestFocus on the JMenu works, but setting the focus to an object just by hovering over it with the mouse provides other problems.
Does anyone knows how I can let a screenreader reads the JMenu-text when hovering with the mouse over the menubar?
I am using Java6 EE and the Java AccesBridge (version 2.02) on a Windows machine (XP and w7).
Swing is the weaker of the GUI technologies relating to accessibility in Java, compared to SWT at any rate. There's a few things you can try.
First is to make sure any accessibility fields are set (which you've started on). I can't remember if Java has an AccessibleRole field, but you can try setting that to menu and menuitem for your menu items.
Another thing you can try is the AccessibleMenu JMenu.AccessibleJMenu component. This one's the product of further reading, so I can't verify it from experience. But it and its surrounding classes may suit your needs.
If those don't work, you could try the option of talking to people's screen readers directly. Quentin C has a good library to do this, Universal Speech. I'm new to this library myself, but it does have a Java implementation in there that should show you how to use it in a Java program. Normally I wouldn't recommend this approach unless making the UI accessible really isn't working.
The last option would be to use the SWT components instead of the Swing ones, even if just for your menu bar. I wasn't sure how keen you'd be on this one, but it is an option and should resolve it.
I hope one of these suggestions helps you solve your problem.
When hovering your mouse over a Class or variable, how come I don't see any information on the type of the class?
Is this not a feature in IntelliJ?
For example, in vs.net, if I mouse over any variable or class it will popup and tell me what namespace that belongs to etc.
And when I am using a method of a class, it also tells me the different overloads for the method (like types for each parameter, and a list of all the overloads).
This must be a feature in IntelliJ, I just don't know how to get it.
Can someone please clear this up?
Also, how can I tidy up the formatting of a page?
It doesn't work on hover yet, please star/vote the issue.
You need to use keyboard shortcuts for quick documentation pop-up or parameter info pop-up (Ctrl+Q and Ctrl+P with default Windows keymap, F1 and Cmd+P with default OS X 10.5+ keymap).
Code | Reformat Code... is the answer to your second question.
Formatting: Code -> Reformat (shortcut: Ctrl-Alt-L)
Hover doesn't produce the kind of information I'd like either. You can get info with Ctrl-Q ("Quick Help") in Windows or F1 in OS X, which will show where it's from and what it is, with most stuff in the popup window linked up in a reasonable way.
That popup view can also be pinned and/or docked; I often have it docked on the bottom.
For example, when I type
Scanner s;
s.
then, right after I type the '.' one popup windows comes up with all the Scanner methods, the first one being highlighted, and a second popup window comes up with the javadoc for that first method (close()). I can use the up and down arrows to select different methods and their docs show up in the second popup. Awesome.
But, when I type:
String s;
s.
then I get the first popup with the methods but not the second popup with the method's javadoc. How do I get that second popup to pop up?
I think this was working before...not sure.
I'm on a Mac.
I visited Preferences->installed JREs and took a look at the current value, which is JVM 1.6.0 (Mac Os X Default). All the Javadoc Locations there point to http://java.sun.com/javase/6/docs/api. Maybe there was some problem downloading these docs?
Ahh, after posting I noticed the url now forwards to oracle so I changed the javadoc URLS to http://download.oracle.com/javase/6/docs/api/ and now it works.
How can I write programs for shortcut keys in java. For Example, ctrl+s means the save option should work. Can anyone help?
Basically you're need to set mnemonics for appropriate buttons. Also you can set some accelerators for menu items. Here is a rather good example.
You want to read the Java tutorial for
Key Listeners
Swing was designed to use Key Bindings for this type of functionality. You create an Action and map a KeyStroke to invoke this Action. Read the section from the Swing tutorial on How to Write an Action for more information.
If you're developing on Mac OS X, use accelerators instead of mnenomics, which are not suppported under the native look and feel Apple Java development guide