event.reset();
event.key = e;
event.readType = ReadType.KEYBOARD;
event.object = object;
event.preprocess = true;
ComponentScreenReader reader = readers.instance(event);
if(TextToSpeechOptions.isScreenReading()) {
reader.read();
}
}
}
return false;//important, do not change
//prevents key from going to editor, if true
}
});
manager.addPropertyChangeListener(this);
MenuSelectionManager menuManager = MenuSelectionManager.defaultManager();
menuManager.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
Object o = e.getSource();
if (o instanceof MenuSelectionManager) {
MenuSelectionManager manager = (MenuSelectionManager) o;
MenuElement[] elements = manager.getSelectedPath();
if (elements.length != 0) {
MenuElement element = elements[elements.length - 1];
event.reset();
event.object = element;
event.readType = ReadType.MENU;
ComponentScreenReader reader = readers.instance(event);
if(TextToSpeechOptions.isScreenReading()) {
reader.read();
}
reader.magnify();
}
}
}
});
runInEventDispatchThread(new Runnable() {
public void run() {
windows = WindowManager.getDefault();
Registry reg = windows.getRegistry();
JFrame frame = (JFrame) windows.getMainWindow();
JRootPane pane = frame.getRootPane();
JLayeredPane layered = pane.getLayeredPane();
Object[] comps = layered.getComponents();
for (int i = 0; i < comps.length; i++) {
if (comps[i] instanceof MenuBar) {
MenuBar bar = (MenuBar) comps[i];
bar.waitFinished();
int num = bar.getMenuCount();
for (int j = 0; j < num; j++) {
Object o = bar.getMenu(j);
if (o != null) {
JMenu menu = (JMenu) o;
menu.addMenuListener(new MenuListener() {
public void menuSelected(MenuEvent e) {
if (e.getSource() instanceof JMenu) {
event.reset();
event.object = e.getSource();
event.readType = ReadType.MENU;
ComponentScreenReader reader = readers.instance(event);
if(TextToSpeechOptions.isScreenReading()) {
reader.read();
}
reader.magnify();
}
}
public void menuDeselected(MenuEvent e) {
}