1

Screen shoot from zk demo

I got an issue from a user. How do I disable dragging of text from a zk component like in my screen shoot above? I am trying in zk demo to drag the value of userName field to password field. I think it's not not only possible in zk. If I am using draggable and dropable property it will be a lot of effort as there are too many components. What should I do?

Malte Hartwig
  • 4,477
  • 2
  • 14
  • 30
syam houng
  • 307
  • 4
  • 14

1 Answers1

2

This kind of drag and drop is a feature accross browsers that allows users to highlight text and then cut or copy it to other places (like Microsoft Word for example, or the browsers's search box).

In order to prevent this, you need to override the browser's default behavior on drag:

<body ondragstart="return false" draggable="false" ...

For more detail, see this answer to a similar question: https://stackoverflow.com/a/1593528/7653073

As the comments on that question point out, you might want to consider leaving it as it is. As it is default browser behavior, users might be missing it.

Malte Hartwig
  • 4,477
  • 2
  • 14
  • 30
  • Yess i agree this is only the default browser behavior and should be not an issue,but when i am using disabled `textbox` with default value and user dragged something and drop it in the textbox it will be a problem. – syam houng May 25 '17 at 08:27
  • @syamhoung I just tried dropping text into a disabled text field `` and nothing happened. The textbox content did not change. – Malte Hartwig May 27 '17 at 14:48