Howto add headers & dividers for a ShowPopupDialog?
-
Hello, i'd like to add headers & dividers to my popup dialog similar to modeling (Mesh menu) popup. Is that possible?
Thanks.
-
Hi - How are you generating the popup dialog right now? Are you using gui.GeDialog to create your own dialog box or are you using c4d.gui.MessageDialog to generate a simple prompt?
I found that I can create the kind of stuff your talking about with gui.GeDialog but it also makes me feel like I'm in over my head - (self taught hack that is distracted easily)
-
Hi, i'm using gui.ShowPopupDialog.
popup = c4d.BaseContainer()
popup.SetString(ID_LIVE_SELECTION, "Live Selection")
result = gui.ShowPopupDialog(cd=None, bc=popup, x=c4d.MOUSEPOS, y=c4d.MOUSEPOS) -
I also would like to know can i add icons to popup menus?
-
Hi, @Gaal-Dornik
Of course you can add header, divider and icon in to Popup dialog.
this is a simple example for how to add title, separator and icon:import c4d def main() -> None: bc = c4d.BaseContainer() bc.InsData(c4d.FIRST_POPUP_ID, "item01") bc.InsData(c4d.FIRST_POPUP_ID+1, "item02") # add a title bc.InsData(0, "This is Title") bc.InsData(c4d.FIRST_POPUP_ID+2, "item03") bc.InsData(c4d.FIRST_POPUP_ID+3, "item04") # add separator bc.InsData(0, "") bc.InsData(c4d.FIRST_POPUP_ID+4, "item05") # add icon for an item bc.InsData(c4d.FIRST_POPUP_ID+5, f"item06 &i{5140}&") bc.InsData(c4d.FIRST_POPUP_ID+6, "item07") res = c4d.gui.ShowPopupDialog(cd=None, bc=bc, x=500, y=500) if __name__ == '__main__': main()
And the result is like this:
You can also visit API Documentation page for more information.
-
That's great! Thanks a lot!)
-
Hello @Gaal-Dornik,
Thank you for reaching out to us. And thank you @gheyret for providing an answer and solution, I do not really have to add anything here.
Cheers,
Ferdinand -
BTW Is there a way to remove 'Type to search' at the top of a popup?
-
Hello @Gaal-Dornik,
I am not quite sure how you mean that. The code example @Gaal-Dornik has provided does not come with the search box (and neither do our code examples). The option has never been documented for Python (I just fixed that) but you must pass
POPUP_ALLOW_FILTERING
as flag when opening the menu to enable the filtering. To disable filtering, you simply must omit the flag (which is the default).Cheers,
FerdinandResult:
Code:
import c4d bc = c4d.BaseContainer() bc.InsData(c4d.FIRST_POPUP_ID, "item01") bc.InsData(c4d.FIRST_POPUP_ID+1, "item02") # add a title bc.InsData(0, "This is Title") bc.InsData(c4d.FIRST_POPUP_ID+2, "item03") bc.InsData(c4d.FIRST_POPUP_ID+3, "item04") # add separator bc.InsData(0, "") bc.InsData(c4d.FIRST_POPUP_ID+4, "item05") # add icon for an item bc.InsData(c4d.FIRST_POPUP_ID+5, f"item06 &i{5140}&") bc.InsData(c4d.FIRST_POPUP_ID+6, "item07") # Redefine the default flags and add the flag which enables the serach box. flags: int = c4d.POPUP_RIGHT | c4d.POPUP_EXECUTECOMMANDS | c4d.POPUP_ALLOW_FILTERING res = c4d.gui.ShowPopupDialog(cd=None, bc=bc, x=500, y=500, flags=flags)
-
That's indeed strange because i haven't included this flag for sure, but i can see this field at the top...
-
Hey @Gaal-Dornik,
I just tried it on
S26.1
and I have the filtering there too no matter what I do:Must have been a bug of S26. I do not see much what you can do here.
Cheers,
Ferdinand -
Actually i've got 'Type to search' popup field in C4D 2023.2.0 also, but POPUP_ALLOW_FILTERING flag is omitted.
Is there a way to hide it? -
It works as expected in C4D 2024, but not in the previous versions.