var selection = window.getSelection();
var selectedTextParts = [];
for (var i = 0; i < selection.rangeCount; i++) {
var range = selection.getRangeAt(i);
selectedTextParts.push(range.toString());
}
See here for more complex uses, like getting the DOM nodes:
https://ubiquity.mozilla.com/hg/ubiquity-firefox/file/tip/ubiquity/modules/contextutils.js
- Blair
On 30/12/09 2:14 AM, Adamantium wrote:
> How would you do multiple selection in a text ( to be precise,
> selection done using ctrl-select)
>
> --
>
> You received this message because you are subscribed to the Google Groups "ubiquity-firefox" group.
> To post to this group, send email to ubiquity...@googlegroups.com.
> To unsubscribe from this group, send email to ubiquity-firef...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/ubiquity-firefox?hl=en.
>
>
On Dec 30, 4:20 am, Blair McBride <unfocu...@gmail.com> wrote:
> The Ubiquity API doesn't provide this, but the DOM API that Ubiquity
> uses does. The key is selection.getRangeAt(x) - using different values
> of x. selection.rangeCount has the number of ranges (areas that are
> selected). So, assuming window is the content window:
>
> var selection = window.getSelection();
> var selectedTextParts = [];
> for (var i = 0; i < selection.rangeCount; i++) {
> var range = selection.getRangeAt(i);
> selectedTextParts.push(range.toString());
>
> }
>
> See here for more complex uses, like getting the DOM nodes:https://ubiquity.mozilla.com/hg/ubiquity-firefox/file/tip/ubiquity/mo...
Yep.
Ubiquity tries to wrap the most used parts various base APIs you
mentioned, but of course it can't do everything :)
- Blair