Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2005-05-14 21:56:51

Yermo
Xinha Authority
From: College Park, Md, USA
Registered: 2005-02-13
Posts: 143
Website

gecko/DOM question - lists and default ENTER key behavior?

I just wanted to see if anyone knows of a way to get out of a list programmatically in FireFox?

If you set config.mozParaHandler to "built-in", which passes the ENTER key onto the internal handler, FireFox correctly "gets out of" ordered and unordered lists on double enter. I presume it's a feature of the in-browser ENTER key handler.

However if you select dirty or best for mozParaHandler, the ENTER behavior is intercepted by dom_checkInsertP() or the EnterParagraphs plugin respectively.

Right now it looks like the only way to to "get out of" the list is to let FireFox process the ENTER keypress internally (i.e. by not calling _stopEvent() and letting firefox do it's thing).

Aside from letting the event propagate into the browser, is there any programmatic way to force your way out of a list? (you'll notice that you can't get out of the list by hitting ENTER twice. You have to select the list icon again which passes the command directly to the browser execCommand.)

thanks,

-- Yermo


-----------------------------------------------------------------------------------------
Content Management with Business Intelligence      [url]http://www.formvista.com[/url]

Offline

#2 2005-05-16 00:15:47

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: gecko/DOM question - lists and default ENTER key behavior?

Taken from dom_checkInsertP this should help

  var sel = this._getSelection();
  sel.removeAllRanges();
  sel.collapse(newblock,0);

that would put the cursor at offset 0 inside newblock (which is just a dom element).


James Sleeman

Offline

#3 2005-05-16 01:10:36

Yermo
Xinha Authority
From: College Park, Md, USA
Registered: 2005-02-13
Posts: 143
Website

Re: gecko/DOM question - lists and default ENTER key behavior?

gogo wrote:

Taken from dom_checkInsertP this should help

[code]  var sel = this._getSelection();
  sel.removeAllRanges();
  sel.collapse(newblock,0);[/code]
that would put the cursor at offset 0 inside newblock (which is just a dom element).

Hmmm. That doesn't seem to be working for me. I'm guessing if you've got:

[code]<ul>
<li><br>
<li>
</ul>
[code]

You would tack on a new block as a nextSibling to <ul> and then collapse to that block as in something like:

[code]
<ul>
<li><br>
</li>
<p>&nbsp</p>[/code]
(I haven't gotten this to work yet). I'm guessing you would have to handle this particular case separately (i.e. an empty list should probably disappear when you hit enter on an empty node .. which is what the built-in handler does ...)

What I've got working here is detecting that I'm on an empty last <li> tag and just returning without calling stopEvent to let the browser handle it ... seems to work but it's a little unclean IMHO.


-----------------------------------------------------------------------------------------
Content Management with Business Intelligence      [url]http://www.formvista.com[/url]

Offline

#4 2005-05-16 01:56:14

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: gecko/DOM question - lists and default ENTER key behavior?

Yes thats what I would have thought, but the selection object for Gecko isn't documented, so it would probably be a matter of experimentation to get it working.

If letting it drop through to the browser works, whats wrong with that?


James Sleeman

Offline

#5 2005-05-16 02:37:20

Yermo
Xinha Authority
From: College Park, Md, USA
Registered: 2005-02-13
Posts: 143
Website

Re: gecko/DOM question - lists and default ENTER key behavior?

gogo wrote:

Yes thats what I would have thought, but the selection object for Gecko isn't documented, so it would probably be a matter of experimentation to get it working.

If letting it drop through to the browser works, whats wrong with that?

Dunno. Seems to work but I'm still new to all of this client side DOM javascript stuff. It seems to me to be a domain of unanticipated consequences so I figured I'd ask. smile

I think I've pretty much figured EnterParagraphs out. It's taken quite a while. Have you looked at that code? If they have an obfuscated Javascript contest I think we should submit it.

It doesn't handle any of the terminal conditions correctly (beginning/end of document, <a> section, <li>, etc. Erroneously generates a false (in getNodeUnder() on _fenEmptySet()) on empty text nodes and causes the left (or right) side range to get duplicated which is why you get those empty <a ..> etc at the end of documents. The coding style is so terribly indirect it's hell trying to figure out what the original author was thinking.

I was on the verge of giving up on it when I made a few breakthroughs. If it continues to go well I should have something to show later this week which also implements the styled <p> tag solution we were discussing a while ago. Getting the same thing to work for MSIE however is going to be cheap trick (put off until later).

You won't like my style and trace messages (of course), but I figure it'll be pretty easy to rip out tracing and  tweak it for whatever style you'd like. It should be an improvement over what's there ...


-----------------------------------------------------------------------------------------
Content Management with Business Intelligence      [url]http://www.formvista.com[/url]

Offline

Board footer

Powered by FluxBB