James wrote regarding 'RE: [EE] IE textRange guru needed' on Tue, Feb 14 at 16:32:
> Now I have another problem. While I was waiting for a reply here, I came up
> with another solution that I like better... I think...
[...]
> So that if you are outside of a bold block, it adds only the and if you
> are inside the bold, it adds only the . E.g. if you click the B you get
> first then you can type your text and when you click the B the second
> time you get
>
> Which do you think is better?
I'm not sure that I personally like one at the exclusion of the other.
I use WordPress to keep a journal of what I've done at work. Calling
it a blog just seems so horrible - I'm keeping notes so people will
know what I did and how to repeat it (or what not to repeat, I
suppose). It uses both behaviors - if text is selected, it wraps the
text with the appropriate tags and positions the cursor after the tags
(I like the positioning inside better, FWIW). If no text is selected
it inserts an open tag and changes the button so it says B* instead of
B, indicating that there's an open bold tag.
I actually think that might be better than detecting what's
appropriate based on where the user's typing. The global toggle shows
the user what htey last opened, and it's up to them to figure out if
theyre in the right place or not. If the toggle's still set when the
user hits submit, a is automatically appended to the end of the
text box. That would be a little more complex to handle with the
current solution, as you'd have to search the text, wheras the toggle
method only requires checking the state of a variable. The toggle
method doesn't depend on browser differences, though, and is a quicker
lookup than a textual search of a potentially long string, so may be
better suited for a JavaScript interface. It also has the benefit of
allowing for a little more obvious user interface - bold is either
"on" or "off".
Both have potential to break an existing tag pair, though, so it might
be worthwhile to do a check before alowing the click - to see if
there's an open bold before the insertion point and, if so, if there's
also a matching close bold after that but before the insertion point.
--Danny
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist