In Target > Info.plist Entries > Simple View > Document Types
How do I associate a text file with a .lyr extension to open with my app?
In Target > Info.plist Entries > Simple View > Document Types
How do I associate a text file with a .lyr extension to open with my app?
You can copy-paste this entry directly double-clicking the Info.plist file (doing it thru the UI editor means a lot of add-type-then-add-then-type-then…). Later, you can browse it in the Simple View list:
Fill as needed the icon, name, etc. The difference between Editor/Viewer in CFBundleTypeRole is only relevant if you are working in a document-based app.
There are more options, such as defining CFBundleTypeOSTypes (old “file types”) or LSTypeIsPackage (true/false). Just open, ie, the Script Editor’s “Info.plist” file and see how is it done…
Thanks
But that’s what I had before when I used the UI. It still won’t associate all .lyr files to my app, either by itself or when I click change all in the info window of a .lyr
When I click change all, this comes up:
Also how do I make my app do something with the file when it is opened?
on open?
I’ve already written the code for pressing command+o within the app, but double-clicking the file doesn’t work.
on choose menu item theObject
if the name of theObject is "open" then
choose file with prompt "Choose .lyr file to open" of type {"TEXT"}
set f to result
set unbinary to read f as string
--descramble
if (count (unbinary)'s words) is greater than 1 then
set the contents of text view 1 of scroll view 1 of window "main" to "This is not a .lyr file"
else
set r to every paragraph of my descramble(unbinary)
--end descramble
set the contents of text field "songname1" of window "main" to item 1 of r as string
set the contents of text field "artistname1" of window "main" to item 2 of r as string
set r to rest of rest of r
repeat with a from 1 to (count r)
set item a of r to {item a of r & return}
end repeat
set the contents of text view 1 of scroll view 1 of window "main" to r as string
end if
end if
if the name of theObject is "save" then
set savefile to the contents of text field "songname1" of window "main" & return & the contents of text field "artistname1" of window "main" & return & the contents of text view 1 of scroll view 1 of window "main" as string
choose file name with prompt "Save As..." default name "untitled.lyr"
set fname to result
scramble(savefile)
set savefile to my scramble(savefile)
set f to paragraph 2 of "
" & (fname)
open for access file f with write permission
write savefile to file f
close access file f
end if
end choose menu item