开发者

How can I detect the operating system using GWT?

开发者 https://www.devze.com 2023-01-28 23:52 出处:网络
Basically what I want to know is to find out if开发者_StackOverflow社区 my GWT application is running on a MacOS or any other operating system, to setup the shortcuts properly using cmd on a MacOS and

Basically what I want to know is to find out if开发者_StackOverflow社区 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.


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".

0

精彩评论

暂无评论...
验证码 换一张
取 消