1
Window / Bug: Window menu doesn't work on OSX
« on: May 19, 2016, 07:55:53 pm »
Hi, I think I found a bug in the OSX version of SFML.
The "Window" menu in the menu bar normally contains the options "Minimize", "Zoom" and "Enter Full Screen", as well as a list of windows. In an SFML program, though these menu items exist, they are greyed out, which also has the unfortunate side-effect that the familiar keyboard shortcuts for these actions don't work either.
I was able to reproduce the problem on a simple program that only creates a window and runs an event loop, and even on all of the examples (except, of course, the command-line ones), which leads me to believe the problem was effectively in SFML.
So, does the problem always happen or is it just on my machine?
EDIT: I tried to associate the "Minimize" menu item with the selector miniaturize: instead of performMiniaturize:. That didn't change anything.
EDIT 2: I was able to get "Minimize" and "Zoom" to work (the items are enabled, and perform the requested function) by associating these menu items with the following custom selectors:
However, this can't be applied to "Enter Full Screen" and the window list, since these are added by the system (presumably during the call to [NSApp setWindowsMenu]).
I believe the problem is that the menu items target the SFApplication instance, when they should target the current key window (NSWindow does have performMiniaturize and performZoom). However, I don't know how to make the binding such that the target changes when a different window becomes key (apart from overriding the delegate to find out when a different window becomes key, but that seems particularly clumsy).
The "Window" menu in the menu bar normally contains the options "Minimize", "Zoom" and "Enter Full Screen", as well as a list of windows. In an SFML program, though these menu items exist, they are greyed out, which also has the unfortunate side-effect that the familiar keyboard shortcuts for these actions don't work either.
I was able to reproduce the problem on a simple program that only creates a window and runs an event loop, and even on all of the examples (except, of course, the command-line ones), which leads me to believe the problem was effectively in SFML.
So, does the problem always happen or is it just on my machine?
EDIT: I tried to associate the "Minimize" menu item with the selector miniaturize: instead of performMiniaturize:. That didn't change anything.
EDIT 2: I was able to get "Minimize" and "Zoom" to work (the items are enabled, and perform the requested function) by associating these menu items with the following custom selectors:
- (void) doMiniaturize: (id) sender {
[[self keyWindow] performMiniaturize: sender];
}
- (void) doZoom: (id) sender {
[[self keyWindow] performZoom: sender];
}
[[self keyWindow] performMiniaturize: sender];
}
- (void) doZoom: (id) sender {
[[self keyWindow] performZoom: sender];
}
However, this can't be applied to "Enter Full Screen" and the window list, since these are added by the system (presumably during the call to [NSApp setWindowsMenu]).
I believe the problem is that the menu items target the SFApplication instance, when they should target the current key window (NSWindow does have performMiniaturize and performZoom). However, I don't know how to make the binding such that the target changes when a different window becomes key (apart from overriding the delegate to find out when a different window becomes key, but that seems particularly clumsy).