Popup button won't work when PullDown option selected in IB

I am using a popup button to collect and display a list of playlists in iTunes and allow a user to select that list.

It works perfectly as long as I do not select the “PullDown” option in the interface builder. However, when I select PullDown, although it triggers the action, the selected menu item on the popup button does not change to the playlist the user selects and it simply returns the current menu item.

Unfortunately, I need the PullDown option using Shadowless Square as I require an oversized popup button and this is the only mode that permits oversized text and a control.

Any ideas on why this doesn’t seem to work properly?

Model: Dual G4
Browser: Safari 417.9.2
Operating System: Mac OS X (10.4)

Can you post the code your using for this PopUp Button?

Sure. It’s pretty simple. The last ‘else if’ properly identifies the popup button and calls handler LoadPlaylists, passing it theObject, which is the popup button.

I know this code works because it loads the popup button properly with the playlists on startup and loads all the tracks in the Library playlist as well. It just won’t change to the playlist you pick off of the popup button

on action theObject
	if name of theObject is "sldMusicSlider" then
		set intPlayerPosition to integer value of theObject
		tell application "iTunes"
			set player position to intPlayerPosition
		end tell
	else if name of theObject is "sldScrollSlider" then
		TrackSliderClick()
	else if name of theObject is "pupPlaylists" then
		LoadPlaylists(theObject)
	end if
	
end action

on LoadPlaylists(objMyPlaylistObject)
	
	set myPlaylistName to title of objMyPlaylistObject --Gets what is currently selected in the popup button
	
	try
	
	tell application "iTunes" to set view of front browser window to playlist myPlaylistName --set iTunes to the playlist selected
	set strTrackSelected to "Getting Track Names..." --A little user feedback in case it takes awhile
	set strArtistName to ""
	set strAlbumName to " "
	SetTrackTitleTextStatus(strTrackSelected)
	SetArtistTextStatus(strArtistName)
	SetAlbumTextStatus(strAlbumName)
	log "MusicTabScripts:LoadPlaylists - Getting Playlist named " & myPlaylistName
	musicGetTrackNames(myPlaylistName, 1) --Go get the track names for this playlist, begin at first item in list
	log "MusicTabScripts:LoadPlaylists - Got track names okay"
	GetTrackInfoForLCD()
	end try
	
end LoadPlaylists

Thanks so much! That did it. I had no idea about the title being the first item. I’ve got it working now.

Hi Jacques (and All),

I am not sure I have the same problem as Bugbyte’s but it seems to belong to this same thread, or at least related to it so I posted it here.

Here is my problem:

I can invoke the necessary actions linked to the chosen or current menu item in the popup list but the checked menu item in that popup list does not change to the selection. It always stays at the topmost or the first item in that list.

Is there a way to update the popup list so that the current menu item is the one that is checked instead of the first item?

Thanks for any lead.

archseed :slight_smile:

I had the same problem. The solution was to set menu item 1 to the selected item.

	set txtListName to (get title of menu item (contents + 1))
			set title of menu item 1 to txtListName

Hi,

Thanks.

I will try that now. I didn’t quite get it the first time around but I think I got it now.

archseed :slight_smile:

Hi,

I tried the suggestion to change the menu item 1 to the title of the selected item and yes, it worked fine. However, this procedure overwrites the default item in the popup list (the first item that is checked).

In order to avoid losing the default item, I had to use the “make” command to create just one item in the popup button list and then set the title of this menu item to the selected item when the button is clicked. I would call this menu item a “special slot” that always holds the title of the current menu item.

After creating the “special slot”, then I add all the items that I want to display in the menu list using another “make” menu item command in a repeat block.

The above technique works. The only lowdown is that the selected menu item is always duplicated. The one that appears at the top of the menu list is checked to indicate that it is the current item. This item has a duplicate in the menu list that is not checked. When the user clicks the popup button to select a new item, the previously checked item is then deselected and is replaced at the top of the list with the new item.

If there is an easier way to update the popup list by highlighting the current menu item instead of placing it at the top of the list, that would be nice. Else, this workaround should be useful.

archseed :slight_smile:

How can you set the check mark on the chosen menu item of a pull down menu? I don’t need to change the title.

If I do nothing, the check mark seems to be completely randomly placed. If I set the current menu item of the popup to anything, then the first item (ie, the second, the one after the title), is always chosen.

— edit —

I figured this out – you have to set the state. But there’s got to be a better way than this? (which works)


set curtit to get title of menu item (contents + 1)
repeat with anitem in menu items
set state of anitem to ((get title of anitem) = curtit)
end repeat

Hi,

Thanks for the tip WoodenBrain.

I gave up using the pull down menu because I wanted to get the current menu item always checked. My previous problem with duplicated current menu item is now resolved. The current menu item stays at the top of the list but the duplicate entry below that no longer shows. I somehow managed to cure that.

Your trick could be useful sometime so I will register it in my brain for future recollection if I need it.

Thanks. Ciao.

archseed :slight_smile: