Hello all,
I have a function:
placeText: Int -> Int -> String -> String -> String -> Svg
placeText xpos ypos pxSize color txt =
Svg.text
[ x (toString xpos)
, y (toString ypos)
, fill color
, fontSize pxSize
{-
, VirtualDom.attribute "-webkit-touch-callout" "none"
, VirtualDom.attribute "-webkit-user-select" "none"
, VirtualDom.attribute "-khtml-user-select" "none"
, VirtualDom.attribute "-moz-user-select" "none"
, VirtualDom.attribute "-ms-user-select" "none"
-}
, VirtualDom.attribute "user-select" "none"
]
[ VirtualDom.text txt ][A minimal complete example using this function is in the three files
attached so you can easily run this if you want.]
It works to place text on my svg drawing area. When I drag the mouse
on the drawing area, the text is selected/highlighted. For my
application, the text should not be selected. How do I control that?
The lines involving VirtualDom.attribute were my attempts to gain
control of that, but they do not work. Advice on StackOverflow at:
http://stackoverflow.com/questions/9627732/drag-and-drop-prevent-awkward-highlightingsays another way to do this is to use a javascript function on the
"drop" event (in my case "mouse up"):
function clearSelection() {
var sel;
if(document.selection && document.selection.empty){
document.selection.empty() ;
} else if(window.getSelection) {
sel = window.getSelection();
if(sel && sel.removeAllRanges)
sel.collapse();
}
}
How can I do the equivalent in elm? The above is an imperative
action, and does not seem to fit in the elm way of doing things,
especially while using virtual-dom diffing. In that architecture, one
can specify that on mouse-up, the model should change in a certain
way, and the view function should render the new model in a certain
way. One can not say that on a mouse-up something should be done
directly. So I need a declarative way to specify properties which can
be included in the view function.
Thanks,
Ambrose