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: Converting Selection to a Range



On May 11, 2005, at 12:01 AM, Paul Ossenbruggen wrote:

Great! That is just what I was looking for. I think it is working. Should I file a bug about the missing functions or is it already reported?

- Paul
On May 10, 2005, at 6:44 PM, Darin Adler wrote:

On May 10, 2005, at 12:33 AM, Paul Ossenbruggen wrote:


In Safari 1.3+, how do you convert a selection retrieved from window.getSelection() to a Range as specified in DOM 2 Ranges? In Mozilla you use getRangeAt() and in IE you use selection.createRange(). It seems that neither is supported with Safari. I was unable to find the W3C DOM way of doing it either. If I use createRange on the document I get an initialized textRange but not one that represents the selection. Safari documentation on this is sparse. Am I missing something obvious?


We should really support both of those!

Unfortunately, Safari 1.3 doesn't support either. But I suggest you try using selection.type to find out the type and then selection.baseNode, selection.baseOffset, selection.extentNode, and selection.extentOffset to get the four values you need to create a range.

-- Darin

That's awesome info and advice. I personally was totally unaware of those properties! I can now find a hint of them in the "source" (Darwin & KDE origin) but where might one look for documentation? I'm only finding this source code via Google at this point. I'm guessing it's defining the accessible properties of the selection object either in JS specifically or some generic IDL definition. Perhaps there is a KHTML doc somewhere outside of google space? Anybody know of a good KHTML/Safari doc that would cover this specialized stuff (simpler than the source :)?


const ClassInfo Selection::info = { "Selection", 0, 0, 0 };
/*
@begin SelectionTable 19
anchorNode Selection::AnchorNode DontDelete|ReadOnly
anchorOffset Selection::AnchorOffset DontDelete|ReadOnly
focusNode Selection::FocusNode DontDelete|ReadOnly
focusOffset Selection::FocusOffset DontDelete|ReadOnly
baseNode Selection::AnchorNode DontDelete|ReadOnly
baseOffset Selection::AnchorOffset DontDelete|ReadOnly
extentNode Selection::FocusNode DontDelete|ReadOnly
extentOffset Selection::FocusOffset DontDelete|ReadOnly
isCollapsed Selection::IsCollapsed DontDelete|ReadOnly
type Selection::_Type DontDelete|ReadOnly
[[==]] Selection::EqualEqual DontDelete|ReadOnly
toString Selection::ToString DontDelete|Function 0
collapse Selection::Collapse DontDelete|Function 2
collapseToEnd Selection::CollapseToEnd DontDelete|Function 0
collapseToStart Selection::CollapseToStart DontDelete|Function 0
empty Selection::Empty DontDelete|Function 0
setBaseAndExtent Selection::SetBaseAndExtent DontDelete|Function 4
setPosition Selection::SetPosition DontDelete|Function 2
modify Selection::Modify DontDelete|Function 3
@end


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

This email sent to email@hidden
References: 
 >Converting Selection to a Range (From: Paul Ossenbruggen <email@hidden>)
 >Re: Converting Selection to a Range (From: Darin Adler <email@hidden>)
 >Re: Converting Selection to a Range (From: Paul Ossenbruggen <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.