Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #16219

Re: Why do I have to click twice?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From "Jukka K. Korpela" <jkorpela@cs.tut.fi>
Newsgroups comp.lang.javascript
Subject Re: Why do I have to click twice?
Date Fri, 28 Sep 2012 09:24:16 +0300
Organization A noiseless patient Spider
Lines 31
Message-ID <k43fqd$ge0$1@dont-email.me> (permalink)
References <fa01218b-c8b1-4f9d-a487-692114175888@h4g2000yqk.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Fri, 28 Sep 2012 06:24:14 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="9e0ae8574c58208bf47738e1c9986fe4"; logging-data="16832"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CYNh7qid3wMt4Xd3vMIDZ"
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20120907 Thunderbird/15.0.1
In-Reply-To <fa01218b-c8b1-4f9d-a487-692114175888@h4g2000yqk.googlegroups.com>
X-Antivirus-Status Clean
X-Antivirus avast! (VPS 120927-1, 27.09.2012), Outbound message
Cancel-Lock sha1:RlKMWQsX04gCtoVz2Kwox3kmWIs=
Xref csiph.com comp.lang.javascript:16219

Show key headers only | View raw


2012-09-28 7:30, justaguy wrote:

> <div id="news" onClick="this.contentEditable='true';">
[...]
> I have to click on the div twice to get it into editing mode, why a
> single click won't do it?  Or the code needs improvement?

The behavior depends on browser. On Chrome and Safari, the cursor 
appears inside the element, in the clicked location, and you can type 
there right away. On Firefox, the cursor does not appear and the element 
takes no normal keyboard input, but Ctrl V pastes the clipboard content 
in the clicked position. On IE and Opera, even Ctrl V does not work 
before you click again. (All tested on Win 7.)

On the browsers tested, the element does not appear as focused in the 
sense of matching the :focus selector in CSS before it is clicked on 
another time.

Confusing, isn't it? It is somewhat obscure what *should* happen. 
Anyway, the behavior becomes more consistent if you append the invocation

this.focus()

at the end of the onclick event handler. Then the element becomes 
focused, the cursor appears, and the element receives immediate keyboard 
input. One problem remains: on Opera, the cursor appears at the start of 
the element content, not in the clicked location, so you need to click 
again in order to insert text somewhere else.

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Why do I have to click twice? justaguy <lichunshen84@gmail.com> - 2012-09-27 21:30 -0700
  Re: Why do I have to click twice? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-09-28 09:24 +0300
    Re: Why do I have to click twice? justaguy <lichunshen84@gmail.com> - 2012-09-28 06:00 -0700

csiph-web