When I create a GeDialog with buttons, the first button is highlighted by default for some reason:
from c4d import gui
MY_PLUGIN_ID = 1234567
GROUP1_ID = 1000
GROUP2_ID = 1001
BUTTON1_ID = 1002
BUTTON2_ID = 1003
BUTTON3_ID = 1004
if self.GroupBegin(GROUP1_ID, c4d.BFH_SCALEFIT | c4d.BFV_SCALE | c4d.BFV_CENTER):
if self.GroupBegin(GROUP2_ID, c4d.BFH_SCALEFIT, 1):
self.AddButton(BUTTON1_ID, c4d.BFH_SCALEFIT | c4d.BFV_SCALE | c4d.BFV_CENTER, name='Button1')
self.AddButton(BUTTON2_ID, c4d.BFH_SCALEFIT | c4d.BFV_SCALE | c4d.BFV_CENTER, name='Button2')
self.AddButton(BUTTON3_ID, c4d.BFH_SCALEFIT | c4d.BFV_SCALE | c4d.BFV_CENTER, name='Button3')
# Main function
example_dialog = Example_Dialog()
example_dialog.Open(c4d.DLG_TYPE_ASYNC, pluginid=MY_PLUGIN_ID, defaultw=300, defaulth=150)
# Execute main()
thank you for reaching out to us. This is the correct behavior of GeDialog. It will always set the focus to its first element, so that users can navigate the dialog with the keyboard. If you look at our asset API examples dialog from the C++ SDK, it has the same behavior:
There are technically two ways to suppress this behavior.
I would say setting the focus to a dummy element is bad because it will break the keyboard input mechanics put into place by Cinema 4D. And I also have not tested what the side-effects of such hack would be. Or to be a bit more direct: This is simply not something you are intended to do. You can always set the focus of gadgets with GeDialog.Activate, but this does not allow you to clear the focus or set it to illegal elements.
Hello @blastframe ,
we will set this topic to 'Solved' when there are no further questions or replies until Monday, November the 22th.
Thank you for your understanding,