How do you set the arrow keys as a key equivilant in Interface Builder?
EDIT: might as well not make a new topic so I’m gonna ask another question here, so I in my iTunes quick song player all it is, is a text field to enter the song, artist or album. but I also have a pop-up menu with the choices of Title Search, Artist Search and Album Search. i want it so if the current item in the pop-up menu is title seach, when you hit enter it searches/plays that song, and the same for artist and album. I already have the script to play the songs, I just don’t know how to work with pop-up menus.
This is my attempted (and failed) script: I’m getting NSReceiverEvaluationScriptError3(1)
on action theObject
if the current menu item of popup button "search_list" of window "mainWindow" is equal to "title_search" then
if the name of theObject is equal to "search_box" then
set songTitle to content of text field "search_box" of window "mainWindow"
repeat
tell application "iTunes"
set fixedIndexing to fixed indexing
set fixed indexing to true
set tracksFound to every track of first library playlist whose name contains songTitle
set foundCount to count of tracksFound
if foundCount is 1 then
set playTrack to beginning of tracksFound
exit repeat
else if foundCount is not 0 then -- greater than 1
set tracksList to {}
repeat with thisTrack in tracksFound
set trackName to name of thisTrack
tell artist of thisTrack to if it is "" then
set trackArtist to "Unknown"
else
set trackArtist to it
end if
tell album of thisTrack to if it is "" then
set trackAlbum to "Unknown"
else
set trackAlbum to it
end if
set trackInfo to trackName & " - " & trackArtist & " (" & trackAlbum & ")" as string
set tracksList to tracksList & trackInfo
end repeat
set trackChosen to choose from list tracksList with prompt ¬
"Your search turned up " & foundCount & " results. Please specify which track you want to play."
if trackChosen is false then
set fixed indexing to fixedIndexing
return
end if
set my text item delimiters to return
set tracksList to tracksList as Unicode text
set my text item delimiters to beginning of trackChosen
set trackNumber to count of paragraphs of first text item of tracksList
set my text item delimiters to ""
set playTrack to item trackNumber of tracksFound
exit repeat
end if
end tell
set songTitle to text returned of (display dialog "Your search turned up 0 results. Try again?." default answer "" buttons {"Cancel", "Go"} default button 2)
end repeat
tell application "iTunes"
play playTrack
set fixed indexing to fixedIndexing
end tell
end if
else if the current menu item of popup button "search_list" of window "mainWindow" is equal to "artist_search" then
if the name of theObject is equal to "search_box" then
set songTitle to content of text field "search_box" of window "mainWindow"
repeat
tell application "iTunes"
set fixedIndexing to fixed indexing
set fixed indexing to true
set tracksFound to every track of first library playlist whose artist contains songTitle
set foundCount to count of tracksFound
if foundCount is 1 then
set playTrack to beginning of tracksFound
exit repeat
else if foundCount is not 0 then -- greater than 1
set tracksList to {}
repeat with thisTrack in tracksFound
set trackName to name of thisTrack
tell artist of thisTrack to if it is "" then
set trackArtist to "Unknown"
else
set trackArtist to it
end if
tell album of thisTrack to if it is "" then
set trackAlbum to "Unknown"
else
set trackAlbum to it
end if
set trackInfo to trackName & " - " & trackArtist & " (" & trackAlbum & ")" as string
set tracksList to tracksList & trackInfo
end repeat
set trackChosen to choose from list tracksList with prompt ¬
"Your search turned up " & foundCount & " results. Please specify which track you want to play."
if trackChosen is false then
set fixed indexing to fixedIndexing
return
end if
set my text item delimiters to return
set tracksList to tracksList as Unicode text
set my text item delimiters to beginning of trackChosen
set trackNumber to count of paragraphs of first text item of tracksList
set my text item delimiters to ""
set playTrack to item trackNumber of tracksFound
exit repeat
end if
end tell
set songTitle to text returned of (display dialog "Your search turned up 0 results. Try again?." default answer "" buttons {"Cancel", "Go"} default button 2)
end repeat
tell application "iTunes"
play playTrack
set fixed indexing to fixedIndexing
end tell
else if the current menu item of popup button "search_list" of window "mainWindow" is equal to "album_search" then
if the name of theObject is equal to "search_box" then
set songTitle to content of text field "search_box" of window "mainWindow"
repeat
tell application "iTunes"
set fixedIndexing to fixed indexing
set fixed indexing to true
set tracksFound to every track of first library playlist whose album contains songTitle
set foundCount to count of tracksFound
if foundCount is 1 then
set playTrack to beginning of tracksFound
exit repeat
else if foundCount is not 0 then -- greater than 1
set tracksList to {}
repeat with thisTrack in tracksFound
set trackName to name of thisTrack
tell artist of thisTrack to if it is "" then
set trackArtist to "Unknown"
else
set trackArtist to it
end if
tell album of thisTrack to if it is "" then
set trackAlbum to "Unknown"
else
set trackAlbum to it
end if
set trackInfo to trackName & " - " & trackArtist & " (" & trackAlbum & ")" as string
set tracksList to tracksList & trackInfo
end repeat
set trackChosen to choose from list tracksList with prompt ¬
"Your search turned up " & foundCount & " results. Please specify which track you want to play."
if trackChosen is false then
set fixed indexing to fixedIndexing
return
end if
set my text item delimiters to return
set tracksList to tracksList as Unicode text
set my text item delimiters to beginning of trackChosen
set trackNumber to count of paragraphs of first text item of tracksList
set my text item delimiters to ""
set playTrack to item trackNumber of tracksFound
exit repeat
end if
end tell
set songTitle to text returned of (display dialog "Your search turned up 0 results. Try again?." default answer "" buttons {"Cancel", "Go"} default button 2)
end repeat
tell application "iTunes"
play playTrack
set fixed indexing to fixedIndexing
end tell
end if
end if
end if
end action