How to not show the popup to cut, copy and paste in textfield
Question

I am developing a mobile application. I am getting a popup when I long tapped the text field with options to cut, copy an paste. I have disabled the cut copy and paste functionality using the following JS code which I got from another question.

document.querySelector("#" + $parameters.inputId).addEventListener("copy", function(event) {

event.preventDefault();

}, false);

document.querySelector("#" + $parameters.inputId).addEventListener("cut", function(event) {

         event.preventDefault();

}, false);

document.querySelector("#" + $parameters.inputId).addEventListener("paste", function(event) {

         event.preventDefault();

}, false);

The cut copy paste functionality is now disabled. How ever, I am still able to see the popup when I long tap in the text field.

Please find the screen shot below


Please post any suggestions to not show this popup or to disable long tap here.

Hi,

Please Check This solution


document.querySelector("#" +$parameters.InputId).addEventListener("contextmenu", function(event) {


         event.preventDefault();


}, false);


Screenshot (172).png

Hey Sundeep,

You may try to disable the text selection or the right click. Here's how: https://www.w3docs.com/snippets/javascript/how-to-disable-text-selection-copy-cut-paste-and-right-click-on-a-web-page.html

Hope this helps!

Hello Sundeep,


You can achieve this  by using jQuery to disable context menu 

You need to add jQuery  to your screen or you can add it to block as per requirement, but first you need to add dependencies, I have attached Oml and Snapshot.
I hope this helps.

Preview Link


Thanks & Regards,

Tousif Khan

Sample_oml_context_menu_restrict.oml

Note that jquery is deprecated, and you shouldn't use it for new projects

Hi,

Please Check This solution


document.querySelector("#" +$parameters.InputId).addEventListener("contextmenu", function(event) {


         event.preventDefault();


}, false);


Screenshot (172).png

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.