I have a scenario where I have some text, which should be user-selectable. The problem is, that there's an UI overlay on top of it, which prevents selecting text by default. The logical way to keep the overlay and still be able to select the text, would be to use synthetic events (use document.createEvent
), but due to some reason, it doesn't work as expected.
The events seem to be delegated correctly and fire their handlers, but no text is selected. I have an example here, which is a rough simplification of the problem.
A few notes
- In Firefox if you start your selection outside of the overlay, you are still able to select the text you want, even if it's under the overlay
- When you have a normal selection in the uncovered area and you click on the overlay, it would be expected from the delegated
mousedown
event to remove the selection, but it doesn't happen
Am I missing an event that should also be delegated (I have mousedown
, mousemove
and mouseup
)? Or is it some kind of a security measure by browsers to disable such behavior (refer to the note nr 2)? Any other suggestions on how to get the desired result? I know I should work around the current overlay solution altogether, but I'm already curious about the problem itself.