示例#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");
            }
        }
示例#2
0
        public void requestScanQr(string webRequestId, bool askJsForValidation, LayoutStrategy layout)
        {
            var layoutAsJson = JsonConvert.SerializeObject(layout);

            BridgeObjectUtil.CallMethodPlain(_impl, nameof(requestScanQr),
                                             webRequestId,
                                             askJsForValidation ? BridgeObjectUtil.True : BridgeObjectUtil.False,
                                             layoutAsJson);
        }
示例#3
0
 public void setToolbarSearchState(bool v)
 {
     BridgeObjectUtil.CallMethodPlain(_impl, nameof(setToolbarSearchState),
                                      //avoid boxing
                                      v ? BridgeObjectUtil.True : BridgeObjectUtil.False);
 }
示例#4
0
 public void setToolbarItems(string menuItemInfosAsJson)
 {
     BridgeObjectUtil.CallMethodPlain(_impl, nameof(setToolbarItems), menuItemInfosAsJson);
 }
示例#5
0
 public void registerMediaAsset(string webRequestId, string fileContent) =>
 BridgeObjectUtil.CallMethodPlain(_impl, nameof(registerMediaAsset), webRequestId, fileContent);
示例#6
0
 public void cancelScanQr(string webRequestId) =>
 BridgeObjectUtil.CallMethodPlain(_impl, nameof(cancelScanQr), webRequestId);
示例#7
0
 public void setToolbarColors(string backgroundColor, string foregroundColor)
 {
     BridgeObjectUtil.CallMethodPlain(_impl, "setToolbarColors", backgroundColor, foregroundColor);
 }
示例#8
0
 public bool hasMediaAsset(string mediaAssetId) =>
 (bool)BridgeObjectUtil.CallMethodPlain(_impl, nameof(hasMediaAsset), mediaAssetId);
示例#9
0
 public bool setPausedScanOverlayImage(string mediaAssetId) =>
 (bool)BridgeObjectUtil.CallMethodPlain(_impl, nameof(setPausedScanOverlayImage), mediaAssetId);
示例#10
0
 public bool setScanSuccessSound(string mediaAssetId) =>
 (bool)BridgeObjectUtil.CallMethodPlain(_impl, nameof(setScanSuccessSound), mediaAssetId);