Exemplo n.º 1
0
        /// <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");
            }
        }
Exemplo n.º 2
0
        private static IAWAppHostApi GetImpl()
        {
            var impl = BridgeObjectUtil.GetFieldValue(Window.Instance, "IAWApp");

            if (impl != null)
            {
                Logger.Debug(typeof(IawAppApi), "has proper IAWApp API");
                return(new IAWAppHostApi(impl));
            }

            Logger.Debug(typeof(IawAppApi), "doesn't have proper IAWApp API");
            return(null);
        }
Exemplo n.º 3
0
        public static void RegisterPostScanQrReplyHandler(string requestId, Action <IAWAppScanReply> action)
        {
            Logger.Debug(typeof(IAWAppHostApi), "RegisterPostScanQrReplyHandler {0}", requestId);
            var handler = BridgeObjectUtil.GetFieldValue(Window.Instance, nameof(androidPostScanQrReply));

            if (handler == null)
            {
                Logger.Debug(typeof(IAWAppHostApi), "setup handler");
                BridgeObjectUtil.SetFieldValue(Window.Instance, nameof(androidPostScanQrReply), (Action <string>)androidPostScanQrReply);
            }
            else
            {
                Logger.Debug(typeof(IAWAppHostApi), "handler already installed");
            }

            _scanQrCallbacks.Add(requestId, action);
        }
Exemplo n.º 4
0
        public static void RegisterPostMediaAssetReady(string requestId, Action <string> action)
        {
            Logger.Debug(typeof(IAWAppHostApi), "RegisterPostMediaAssetReady {0}", requestId);
            var handler = BridgeObjectUtil.GetFieldValue(Window.Instance, "androidPostMediaAssetReady");

            if (handler == null)
            {
                Logger.Debug(typeof(IAWAppHostApi), "setup handler");
                BridgeObjectUtil.SetFieldValue(Window.Instance, nameof(androidPostMediaAssetReady), (Action <string, string>)androidPostMediaAssetReady);
            }
            else
            {
                Logger.Debug(typeof(IAWAppHostApi), "handler already installed");
            }

            _mediaReadyCallbacks.Add(requestId, action);
        }