/// <summary>input must be focused in order for createTextRange() to work ! </summary> /// <param name="self"></param> public static void SelectWholeTextAndMoveCursorToEnd(this Element self) { //original idea from https://css-tricks.com/snippets/javascript/move-cursor-to-end-of-input/ if (self.HasFieldOrMethod("selectionStart") && self.IsFieldReadable("selectionStart")) { var selectionStart = self.GetFieldValue("selectionStart"); if (Script.TypeOf(selectionStart) != "number") { return; } var len = self.GetFieldValue("value.length"); self.SetFieldValue("selectionStart", 0); self.SetFieldValue("selectionEnd", len); return; } var createTextRange = BridgeObjectUtil.GetFieldValue(self, "createTextRange"); if (BridgeObjectUtil.HasFieldOrMethod(self, "select")) { BridgeObjectUtil.CallMethodPlain(self, "select"); } if (Script.TypeOf(createTextRange) != "undefined") { var range = BridgeObjectUtil.CallSelf(createTextRange); BridgeObjectUtil.CallMethodPlain(range, "collapse", false); BridgeObjectUtil.CallMethodPlain(range, "select"); } }
public static EnvironmentType GetInstanceFromWindow(WindowInstance win) => (win.Navigator.UserAgent.Contains("IndustrialAndroidWebApp") || BridgeObjectUtil.HasFieldOrMethod(win, "IAWApp")) ? EnvironmentType.IndustrialAndroidWebApp : EnvironmentType.Desktop;