On Thu, 15 Jun 2006 08:16:31 +0200, Wayne Melrose <email@hidden>
said:
>Hi,
>
>I really would like to use a browser in my new application. Although
>I have looked at the example "Browser" application supplied with
>Xcode and each time I look at it I continue to be stumped by it.
>
>I was wondering if someone has some simple, understandable code, (or
>even just some different code) to what is supplied in that example,
>to help me understand how to use it. (To populate and also retrieve
>data)
Yes, it's tricky, and it's made even more tricky by the fact that there are
two related bugs in AppleScript Studio:
(1) You need to know what row is selected in each column, in order to know
what to display in the next column; but you can't find that out without
using call method, as the needed method is not bridged.
(2) A browser has a "path" property, which you may need; but unfortunately
there is more than one "path" property in AppleScript Studio's terminology,
so you can't say the "path" you need to say.
It isn't really much better in Cocoa / Objective-C. But it's better,
especially if you use NSTreeController in which case all the work is done
for you. So I advise you look into that. If you still refuse to take good
advice when it's offered, then the following will get you started. Be sure
to fix the line wrapping and the chevrons if they are destroyed by the
email. m.
=================
property L : {"root", {{"marx", {"groucho", "chico", "harpo", "zeppo",
"gummo"}}, {"pep", {"mannie", "moe", {"jack", {"flash", "straw"}}}}}}
on dive(theBrowser, theColumn)
return item 2 of diveHelper(theBrowser, theColumn - 1)
end dive
on diveHelper(b, i)
if i = 0 then return L
return item ((call method "selectedRowInColumn:" of b with parameter (i
- 1)) + 1) of item 2 of diveHelper(b, i - 1)
end diveHelper
on will display browser cell theObject in column inColumn browser cell
browserCell row theRow
local ansr
set ansr to item theRow of dive(theObject, inColumn)
if class of ansr is list then
set leaf of browserCell to false
set string value of browserCell to item 1 of ansr
else
set leaf of browserCell to true
set string value of browserCell to ansr
end if
end will display browser cell
on number of browser rows theObject in column inColumn
return count (dive(theObject, inColumn))
end number of browser rows
on clicked theObject
set s to (run script "get «property patA» of browser 1 of window 1")
display dialog s
end clicked
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden
This email sent to email@hidden