I tried something similar some time ago, and it's a pain. I'm not sure whether you can at all detect all possible keystrokes correctly, not to speak of accented characters and such. I'd probably go with an HTML <input> field inside a <foreignObject> right now, since the editable text currently is only supported by Opera, I believe. I would replace the to-be-edited-text with an <input>, and when editing is done, I would swap back the text element with updated content. I didn't try it, but I think it should be possible.
Thomas W. --- In [email protected], "gb_n_svg" <gbulmeruk@...> wrote: > > I'd like to know what is the 'right way' to do text input in pure SVG? > (I am building a pure SVG user interface.) > > I have lots of different shapes (over 100), each made from a group containing > paths, rectangles and text elements (eventually filters too). > > The user can 'clone' any shape by dragging it and dropping. > They need to be able to type some text into *one* of the text fields within > the group, just one word or a number. (Some text is the applications labels, > and can't be changed by the user) > > I would like to stretch the shape as they type reach character if the text > they are entering is approaching one of the other fields on the shape, or the > edge of the shape. I'd like to shrink the shape, if they rub out a character. > They should be able to click into the middle of the text, and drive left and > right with the cursor keys. I don't need to support tabbing from one field to > the next. > > The shape is quite complex, so expanding or shrinking while they type may > need the path 'd' attribute value to be changed dynamically. Is that an okay > idea, or do I need to try to design the shapes' geometry to avoid it? > > I'd also like to support drop-down lists around the text input (for 'standard > values' or their most recent entries) > > Would someone please point me at the stuff I should be reading or > googling-for to understand the available approaches to text input? Simple > searches like "SVG text input" doesn't seem to find anything helpful. > > Do I need to handle every key stroke myself, or are there some helper > mechanisms that I can hook into? For example, when I used to do X-Windows > stuff, editing could be handled by a widget, but it was possible to look at > every character too (both before and after the widget saw it, I think; 19 > years ago, so I may be wrong). > > I'd like to get reasonably wide deployment (when Firefox 4, and IE9 arrive). > Should I be constraining myself to SVG 1.1, and ignore the SVG 1.2 (I see > that 1.2 seems to have editable text support)? > > Or, should I be using XHTML too, and abandon a pure SVG approach? > > All help welcomed :-) > GB-) > ------------------------------------ ----- To unsubscribe send a message to: [email protected] -or- visit http://groups.yahoo.com/group/svg-developers and click "edit my membership" ----Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/svg-developers/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/svg-developers/join (Yahoo! ID required) <*> To change settings via email: [email protected] [email protected] <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

