Hey @fwilleke80,
I know that I always say that, but that question is ambiguous :) What is being broadcasted to a dialog, depends on the gadgets that are in the dialog, and which one is focused. In short, not everything receives the full input stream. But a dialog itself should receive all keyboard events.
I also faintly remembered that the ESC
key is handled separately in all the ancient GUI backend, hence the symbol BFM_ACTION_ESC
. For the dialog from above, and this message method,
def Message(self, msg: c4d.BaseContainer, result: c4d.BaseContainer) -> int:
"""Called by Cinema 4D to convey events to the dialog.
"""
mid: int = msg.GetId()
if mid == c4d.BFM_LOSTFOCUS:
self.Close()
elif mid in (c4d.BFM_ACTION, c4d.BFM_INPUT):
symbol: str = "BFM_ACTION" if mid == c4d.BFM_ACTION else "BFM_INPUT"
print ("-" * 79)
print (f"{symbol}: {msg[c4d.BFM_ACTION_VALUE] = }")
print (f"{symbol}: {msg[c4d.BFM_ACTION_ESC] = }")
print (f"{symbol}: {msg[c4d.BFM_ACTION_ID] = }")
print (f"{symbol}: {msg[c4d.BFM_INPUT_VALUE] = }")
print (f"{symbol}: {msg[c4d.BFM_INPUT_VALUE_REAL] = }")
print (f"{symbol}: {msg[c4d.BFM_INPUT_ASC] = }")
return super().Message(msg, result)
and pressing first ESC
and then e
, I got this output:
-------------------------------------------------------------------------------
BFM_ACTION: msg[c4d.BFM_ACTION_VALUE] = 1
BFM_ACTION: msg[c4d.BFM_ACTION_ESC] = None
BFM_ACTION: msg[c4d.BFM_ACTION_ID] = 2
BFM_ACTION: msg[c4d.BFM_INPUT_VALUE] = None
BFM_ACTION: msg[c4d.BFM_INPUT_VALUE_REAL] = None
BFM_ACTION: msg[c4d.BFM_INPUT_ASC] = None
-------------------------------------------------------------------------------
BFM_INPUT: msg[c4d.BFM_ACTION_VALUE] = None
BFM_INPUT: msg[c4d.BFM_ACTION_ESC] = None
BFM_INPUT: msg[c4d.BFM_ACTION_ID] = None
BFM_INPUT: msg[c4d.BFM_INPUT_VALUE] = 1
BFM_INPUT: msg[c4d.BFM_INPUT_VALUE_REAL] = 1.0
BFM_INPUT: msg[c4d.BFM_INPUT_ASC] = 'e'
So, pressing ESC
is an action and not an input event in a dialog (when the dialog itself is focused), because everything else would be too easy, right? However, nothing among the usual suspects conveys clearly that this is an ESC
-button press event. Noteworthy is however the action ID 2
, neither the dialog itself nor any of the gadgets has that ID, so it could be that it encodes that this is the ESC
button being pressed while the dialog itself is in focus. But that is pure speculation.
Hopefully, this gets you started. For a more concrete answer, I would have to start digging around in the GUI backend to see what is what. I currently do not have the time to do that, as we are quite busy now. When you are still stuck, please drop me a note here, and I will see if I can squeeze in some time next week.
Thank you for your understanding,
Ferdinand
PS: There is nothing else in that message container when ESC
is being pressed.

Full code:
"""Implements a dialog which behaves similar to the asset selection dialogs.
"""
import c4d
import random
class TestDialog(c4d.gui.GeDialog):
"""
"""
def CreateLayout(self) -> bool:
"""Called by Cinema 4D to populate the dialog with gadgets.
"""
self.SetTitle("Test")
for i in range(1000, 1011):
label: str = "".join(chr (random.randint(41, 90)) for _ in range(20))
self.AddStaticText(i, c4d.BFH_SCALE, name=label)
return True
def Message(self, msg: c4d.BaseContainer, result: c4d.BaseContainer) -> int:
"""Called by Cinema 4D to convey events to the dialog.
"""
mid: int = msg.GetId()
if mid == c4d.BFM_LOSTFOCUS:
self.Close()
elif mid in (c4d.BFM_ACTION, c4d.BFM_INPUT):
symbol: str = "BFM_ACTION" if mid == c4d.BFM_ACTION else "BFM_INPUT"
print ("-" * 79)
print (f"{symbol}: {msg[c4d.BFM_ACTION_VALUE] = }")
print (f"{symbol}: {msg[c4d.BFM_ACTION_ESC] = }")
print (f"{symbol}: {msg[c4d.BFM_ACTION_ID] = }")
print (f"{symbol}: {msg[c4d.BFM_INPUT_VALUE] = }")
print (f"{symbol}: {msg[c4d.BFM_INPUT_VALUE_REAL] = }")
print (f"{symbol}: {msg[c4d.BFM_INPUT_ASC] = }")
return super().Message(msg, result)
if __name__ == "__main__":
dlg: TestDialog = TestDialog()
dlg.Open(c4d.DLG_TYPE_MODAL_RESIZEABLE, 0, 500, 500)