Hello,
I have a simple app with a NSButton and a NSMenu with 3 NSMenuItem, The menu is set for the NSButton using setMenu() and works as a context menu for it.
I also added a timer to my app (the timer is added to the main loop so it ticks even when the menu is visible).
In the timer is prints:
<start code>
NSLog(@"-------------------------------------- Timer tick ");
NSWindow* mainWindow = [NSApp mainWindow];
NSWindow* keyWindow = [NSApp keyWindow];
NSWindow* accMainWindow = [NSApp accessibilityAttributeValue: NSAccessibilityMainWindowAttribute];
NSWindow* accFocusedWindow = [NSApp
accessibilityAttributeValue: NSAccessibilityFocusedWindowAttribute];
id accElement = [NSApp accessibilityAttributeValue: NSAccessibilityFocusedUIElementAttribute];
id accElementFocus = [NSApp accessibilityFocusedUIElement];
NSLog(@"main window %@", mainWindow);
NSLog(@"key window %@", keyWindow);
NSLog(@"acc main window %@", accMainWindow);
NSLog(@"acc focused window %@", accFocusedWindow);
NSLog(@"acc ui element %@", accElement);
NSLog(@"acc ui element
fcous %@", accElementFocus);
NSLog(@"button %@", button);
NSLog(@"button cell %@", [button cell]);
<end code>
The window is always my window, the accElement and accElementFocus are always the button cell.
This is true even when the context menu is up, and voice over is reading the selected menu item in it.
In short, my question is, if
the window and the focused ui element are still back to the main window at the button cell how does VO knows how to read from the menu ?
In my application is more complicated, the menu is hosted in a separate window (NSPanel). Even when the menu is up, the window with the button remains as the key window and main window for the app. There is special code to route the events from the main window to menu window.
Thank you
Felipe