GeDialog Button Highlighted By Default
-
Hello,
When I create a GeDialog with buttons, the first button is highlighted by default for some reason:import c4d from c4d import gui MY_PLUGIN_ID = 1234567 GROUP1_ID = 1000 GROUP2_ID = 1001 BUTTON1_ID = 1002 BUTTON2_ID = 1003 BUTTON3_ID = 1004 class Example_Dialog(gui.GeDialog): def CreateLayout(self): self.SetTitle("BUTTON_HIGHLIGHTED") self.GroupBorderSpace(10,10,10,10) if self.GroupBegin(GROUP1_ID, c4d.BFH_SCALEFIT | c4d.BFV_SCALE | c4d.BFV_CENTER): if self.GroupBegin(GROUP2_ID, c4d.BFH_SCALEFIT, 1): self.GroupBorderSpace(5,5,5,5) 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') self.GroupEnd() self.GroupEnd() return True # Main function def main(): global example_dialog example_dialog = Example_Dialog() example_dialog.Open(c4d.DLG_TYPE_ASYNC, pluginid=MY_PLUGIN_ID, defaultw=300, defaulth=150) # Execute main() if __name__=='__main__': main()
-
Hello @blastframe,
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.
- Simply dock the dialog with a layout, given it is non-modal dialog, which seems to be the case in your example.
- There is technically the private message
BFM_SETFOCUS
with which this behavior might be altered, but that requires some jumping through hoops and is probably also intentionally private, so I cannot really share it without a good reason. I think you will always need dummy element, e.g., a static text with no string, to make this work. So that you can set the focus to that element. By default, Cinema 4D will ignore such static text element as the first element.
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.Cheers,
Ferdinand -
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,
Ferdinand