I can’t find something similar to a drop-down list in DirectGUI. https://www.google.com/search?q=drop+down+list
Sure, one could be created from scratch by combining a DirectButton that toggles a DirectFrame with a DirectScrollbar and having buttons inside it or toggles a DirectScrolledFrame with DirectButtons inside it, but I wanted to make sure something simple like a DirectDropdownList didn’t exist first which does the same itself.
DirectOptionMenu might serve your purpose.
It doesn’t behave exactly like a standard drop-down menu (for one thing, the menu isn’t positioned strictly below the associated button, as I recall), but it may work. And if not, you could perhaps sub-class it and simply tweak its behaviour as appropriate.
Hi @Thaumaturge ,
I tried running the example code from that manual page and DirectOptionMenu seems to be broken in Panda 1.10 and throws this error:
Traceback (most recent call last):
File “test.py”, line 26, in
highlightColor=(0.65, 0.65, 0.65, 1))
File “C:\Panda3D-1.10.3-x64\direct\gui\DirectOptionMenu.py”, line 48, in init
self.initPopupMarkerPos = self[‘popupMarker_pos’]
File “C:\Panda3D-1.10.3-x64\direct\gui\DirectGuiBase.py”, line 477, in cget
'" for ’ + self.class.name)
KeyError: ‘Unknown option “popupMarker_pos” for DirectOptionMenu’
And the description seems confusing to understand whether it is what I need. “The popup menu appears when the menu is clicked on and disappears when the user clicks again”. Clicks the “menu”? So the menu appears when the menu is clicked? Something is not right with this sentence.
@rdb A screenshot of what each DirectGUI element looks like in the manual pages would help too.
Try upgrading your installation of Panda: the issue that you see there was, I believe, fixed in a bug-fix release.
In short, this is what it’s trying to convey, I believe:
When you create a DirectOptionMenu, you’re presented with a button. Clicking on this button causes the pop-up menu to appear. When the pop-up menu is open, either selecting an item from the pop-up menu or clicking elsewhere should close the menu.
Not a bad idea!
Right you are, on this machine I hadn’t upgraded from 10.0.3.
I think the manual page text should be reworded. This is basically what a drop down list is except the list doesn’t necessarily drop “down” which I couldn’t have guessed from the wording in the manual.
I’d suggest adding an entry to the documentation GitHub issue-list, in that case.