问题
Basically what I want to know is to find out if my GWT application is running on a MacOS or any other operating system, to setup the shortcuts properly using cmd on a MacOS and ctrl everywhere else.
回答1:
You can use:
import com.google.gwt.user.client.Window.Navigator;
...
String platform = Navigator.getPlatform();
This returns a String (the same as JavaScript's navigator.platform
). You can then decide on the OS similar to this script: It simply checks for the substring "Win"/"Mac"/"iPhone"/"Linux".
来源:https://stackoverflow.com/questions/4372443/how-can-i-detect-the-operating-system-using-gwt