hasMouse method

bool hasMouse ()

Get Apple OS version (major and minor). try to find something like "CPU OS 9_0 or CPU OS 9_0_1", which is typical for iOS (also OS X ??) Return e.g. 9, 0 or [9, 0, 1. This was tested on iPad for iOS 9.0.1. Return null if no proper format found. / InfoDialog.noModal(window.navigator.userAgent, null); / InfoDialog.noModal("2=${versionString} ${index}", null); / InfoDialog.noModal("3=${versionString} ${index}", null); / InfoDialog.noModal("4=${temp}", null); Get Chrome version, works for Window, Android, .. (so far major). try to find something like "Chrome/48.0.2564.195.567". Return e.g. 48, 0 or 48, 0, 2564. Return null if no proper format found. / InfoDialog.noModal(window.navigator.userAgent, null); / InfoDialog.noModal("2=${versionString} ${index}", null); / InfoDialog.noModal("4=${temp}", null); Returns true if SpecPad is operated via mouse rather than finger. Currently identical to isTablet(). TODO: Event if tablet: mouse could be present, detect that.

Implementation

//List<int> getVersionApple() {
//  int index = window.navigator.userAgent.indexOf("CPU OS ");
////  InfoDialog.noModal(window.navigator.userAgent, null);
//  if (index == -1) return null;
//  index += "CPU OS ".length;
//
//  String versionString = window.navigator.userAgent
//      .substring(index, index + 10); // get "9_0" from "9_0 XXXXX..."
//  index = versionString.indexOf(" ");
////  InfoDialog.noModal("2=${versionString} ${index}", null);
//  if (index == -1) return null;
//
//  versionString = versionString.substring(0, index); // now we have "9_0".
//  index = versionString.indexOf("_"); // split in major/minor
////  InfoDialog.noModal("3=${versionString} ${index}", null);
//  if (index == -1) return null;
//
//  List<String> temp = versionString.split("_");
////  InfoDialog.noModal("4=${temp}", null);
//  if (temp.length == 2) // 9_0
//  {
//    return [int.parse(temp[0]), int.parse(temp[1])]; // [9,0]
//  } else if (temp.length == 3) // 9_0_1
//  {
//    return [
//      int.parse(temp[0]),
//      int.parse(temp[1]),
//      int.parse(temp[2])
//    ]; // [9,0,1]
//  }
//  return null;
//}

/// Get Chrome version, works for Window, Android, .. (so far major).
/// try to find something like "Chrome/48.0.2564.195.567".
/// Return e.g. [48, 0] or [48, 0, 2564].
/// Return null if no proper format found.
//List<int> getVersionChrome() {
//  int index = window.navigator.userAgent.indexOf("Chrome/");
////  InfoDialog.noModal(window.navigator.userAgent, null);
//  if (index == -1) return null;
//  index += "Chrome/".length;
//
//  String versionString = window.navigator.userAgent
//      .substring(index, index + 12); // get "9_0" from "9_0 XXXXX..."
//  index = versionString.indexOf(".");
////  InfoDialog.noModal("2=${versionString} ${index}", null);
//  if (index == -1) return null;
//
//  List<String> temp = versionString.split(".");
////  InfoDialog.noModal("4=${temp}", null);
//  if (temp.length == 2) // 48.0
//  {
//    return [int.parse(temp[0]), int.parse(temp[1])]; // [9,0]
//  } else if (temp.length > 2) // 48.0.9257.5
//  {
//    return [
//      int.parse(temp[0]),
//      int.parse(temp[1]),
//      int.parse(temp[2])
//    ]; // [9,0,1]
//  }
//  return null;
//}

/// Returns true if SpecPad is operated via mouse rather than finger.
/// Currently identical to isTablet().
///  TODO: Event if tablet: mouse could be present, detect that.
static bool hasMouse() {
  return !isTablet();
}