On 09/09/2014 at 11:23, xxxxxxxx wrote:
That code is for a GeDialog. But you're using it in a CommandData class.
The CommandData class is only used to give you a way to launch the GeDialog from the menu. So you need to write your gizmo code for a GeDialog class.
Put this code in your script manager and run it.
Then RMB click in the dialog and select an item from the popup list. And it will put what you selected in the textbox.
This is a script example. But works the same way in plugins.
import c4d
from c4d import gui
class CustomDialog(c4d.gui.GeDialog) :
def CreateLayout(self) :
self.AddEditText(2222, c4d.BFH_CENTER, initw=120, inith=15)
return True
def Message(self, msg, result) :
if msg.GetId() == c4d.BFM_INPUT:
if msg.GetLong(c4d.BFM_INPUT_CHANNEL)==c4d.BFM_INPUT_MOUSERIGHT:
#Put in your code which will be executed upon a RMB click
entries = c4d.BaseContainer()
entries.SetString(1000, 'Item 1')
entries.SetString(1001, 'Item 2')
entries.SetString(0, "") #Using a 0 Adds a separator
entries.SetString(1003, 'Item 3')
popupGizmo = c4d.gui.ShowPopupDialog(cd=None, bc=entries, x=c4d.MOUSEPOS, y=c4d.MOUSEPOS)
popupText = entries.GetString(popupGizmo)
self.SetString(2222, popupText)
return c4d.gui.GeDialog.Message(self, msg, msg)
def main() :
myDialog = CustomDialog()
myDialog.Open(dlgtype=c4d.DLG_TYPE_MODAL_RESIZEABLE, pluginid=1000001, defaultw=150, defaulth=100, xpos=-1, ypos=-1)
if __name__=='__main__':
main()
-ScottA