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