Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Keeping focus on an editable div.



Solved this.  There are a couple (so far as I can tell undocumented) CSS attributes that took care of the problem.  I hope that they are safe to use (i.e. public APIs):

    -khtml-user-modify:read;
    -khtml-user-select:text;

Another undocumented feature (a function this  time) I needed to implement selectAll was:

    window.getSelection().setBaseAndExtent(myDiv, 0, myDiv, myDiv.innerText.length-1);

And, by the way, if you want to do this immediately after something like:

    myDiv.innertText = "Some darn thing";

You'll want to call with a delay using:

    setTimeout('selectAll();', 0);

-Tom


On May 9, 2005, at 4:32 PM, Tom Bunch wrote:

I'm working on a widget that takes a page from Stickies' book, as it were, but I can't see to get keyboard focus into my content-editable div.  I can start it there, but if I click anywhere, including within the content area of said div, I can't get focus back.  WebKit's implementation of <DIV> doesn't appear to support focus().  If anyone knows how to approximate the same thing, please let me know.

I haved pared my widget down to minimal source and confirmed that the code works as expected in Safari.  It doesn't work in a widget.  Here's a zip:


The actual widget is of course rather more complicated.  I would prefer to use an editable div rather than a textarea if possible.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Dashboard-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Dashboard-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/dashboard-dev/email@hidden

This email sent to email@hidden

References: 
 >Keeping focus on an editable div. (From: Tom Bunch <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.