Mime-Version: |
1.0 (Apple Message framework v1082) |
Sender: |
|
Date: |
Sun, 26 Dec 2010 18:19:57 +0900 |
Reply-To: |
|
Subject: |
|
From: |
|
Content-Transfer-Encoding: |
quoted-printable |
In-Reply-To: |
|
Content-Type: |
text/plain; charset=us-ascii |
Comments: |
|
Parts/Attachments: |
|
|
Hello Nobumi,
On Dec 26, 2010, at 5:17 PM, Nobumi Iyanaga wrote:
>> Same with selectedSubstrings command. This is why $selectedTexts.count in your macro returns 1 when just an insertion point exists in the frontmost document window.
>
> This is still difficult to understand. If the index of array is zero-based, I would understand better, if "$selectedTexts.count" returned 0 (that is one selection), instead of 1...??
Ah, but what count does is just to return the number of values in an array and values may be empty strings.
And, personally, I would be very much confused if textSelections and selectedSubstrings returned different values because, in my understanding, selectedSubstrings is a kind of shorthand which is equivalent to...
$doc = Document.active
$sels = $doc.textSelections
$substrings = Array.new
foreach $sel in $sels
$substrings.appendValue $sel.substring
end
exit $substrings
> And what is the normal way to verify if there is/are selection(s) in a document?
How about this? I don't think there is a standard way for that, though.
$sel = TextSelection.active
if $sel == undefined
exit 'No open document or the focus in a non-text object (floating image or something else?)'
elsif $sel.length
exit 'One or more characters (or in-line images) selected'
else
exit 'Just a caret (zero-width selection)'
end
Kino
|
|
|