Disable selection of text

Discuss SVG code, accessible via the XML Editor.
katun89
Posts: 12
Joined: Sat Jan 08, 2011 12:57 pm

Disable selection of text

Postby katun89 » Tue Jan 11, 2011 3:14 pm

Hi guys,
as the subject says: is tehere anyway to disable the selection of a text element?

Here I have a simple circle with a number within: if u click 2 times the browser select the number to let you copy it, but I need to prevent this selection.

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   version="1.1"
   width="100%"
   height="100%"
   viewBox="0 0 1552 881"
   id="svg2">
 
  <path
     d="m 547.74525,358.7305 a 166.4716,146.78142 0 1 1 -332.9432,0 166.4716,146.78142 0 1 1 332.9432,0 z"
     id="italia"
     style="fill:#000000;stroke:#000000;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
     onclick="change(evt)" />
     <text id="italia value" onclick="change(id)" fill="#FFFFFF" stroke="black" font-size="200" font-family="Verdana" x="260" y="430">11</text>
</svg>

User avatar
Bucic
Posts: 128
Joined: Fri Apr 24, 2009 2:50 am
Location: Poland

Re: Disable selection of text

Postby Bucic » Sun Jan 16, 2011 4:42 am

It's totally not my level but can't you just convert the number to path? :) The same thing you do to ensure your text in SVG will display same on different computers with different fonts installed.
!!! Support wishlist: A new perspective / transformation tool http://tinyurl.com/3uacua4
* Inkscape Tutorial Basics A different approach... http://tinyurl.com/3pextp3
* What do I use Inkscape for http://tinyurl.com/3pbna6l

rubenred
Posts: 2
Joined: Fri Sep 30, 2011 5:15 pm

Re: Disable selection of text

Postby rubenred » Fri Sep 30, 2011 5:18 pm

very simple, put a layer on top of the text layer and set its transparency to 0 :D
Attachments
transparency_text.svg
(2.63 KiB) Downloaded 372 times

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Disable selection of text

Postby brynn » Sat Oct 01, 2011 6:39 am

Welcome to InkscapeForum, rubenred!

I don't think putting a transparent layer on top of it is going to help. You'll still select the text. And I should say that I'm talking about on the canvas. katun89 is using code, for one thing, and it sounds like on a webpage for another. So I'm completely at a loss to offer help. But I do know, that whether by code or by gui, a transparent layer won't help, either on the canvas, or by the time it gets to a webpage.

I've looked at your file, and I don't even see a 2nd layer, much less a transparent one. It's just some text, and when I double-click, it's selected with the Text tool. Oh ok, I see that you've put a transparent rectangle over the text. But that does not prevent the selection, at least on the canvas. Even though the op is using it on a webpage (it sounds like), I think they'll have the same problem.

Now, if you set the same rectangle (or whatever) above it, but set the opacity to 0.01, THAT might work. On the canvas, you would actually select the rectangle. With code and/or webpage, I have no idea what would happen, or how to do it.

rubenred
Posts: 2
Joined: Fri Sep 30, 2011 5:15 pm

Re: Disable selection of text

Postby rubenred » Sat Oct 01, 2011 6:50 am

open the svg file on IE or Firefox with SVG Viewer plugin installed. you will not be able to select the text


Return to “SVG / XML Code”