Solved Selecting the text in a GeDialog MultiLineEditText

Hello,
How does one select all of the text in a GeDialog.AddMultiLineEditText gadget?

    def CreateLayout(self):
        self.AddMultiLineEditText(self.multiText, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT,
            initw=0, inith=0, style=c4d.DR_MULTILINE_WORDWRAP)
        self.SetString(self.multiText,"Placeholder Text.")
        self.Activate(self.multiText)
        return True

I tried getting Message IDs when selecting the text with a right-click > Select All, but all I could trace was BFM_INTERACTSTART and BFM_INTERACTEND.

I am trying to create a behavior similar to the InputDialog where the text is already selected.

c4d.gui.InputDialog("Dialog Title","Placeholder Text")

Thank you!

This can be done by sending directly the correct message:

bc = c4d.BaseContainer(c4d.IDM_SELECTALL)
self.SendMessage(10000, bc)  # 10000 is the ID of the MultiLineEditText gadget

And here a complete example:

import c4d

class ExampleDialog(c4d.gui.GeDialog):

    def CreateLayout(self):
        self.SetTitle("This is an example Dialog")

        my_text = """jfsdskdhsdfsd
        fsd
        fsd
        sdf
        sddsf
"""
        self.AddMultiLineEditText(10000, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, style=c4d.DR_MULTILINE_MONOSPACED | c4d.DR_MULTILINE_HIGHLIGHTLINE | c4d.DR_MULTILINE_READONLY)

        self.SetString(10000, my_text)

        # Creates a Ok and Cancel Button
        self.AddDlgGroup(c4d.DLG_OK | c4d.DLG_CANCEL)

        return True

    def Command(self, messageId, bc):
        if messageId == c4d.DLG_OK:
            bc = c4d.BaseContainer(c4d.IDM_SELECTALL)
            self.SendMessage(10000, bc)
            
            return True
        elif messageId == c4d.DLG_CANCEL:
            self.Close()

        return True


def main():
    dlg = ExampleDialog()

    dlg.Open(c4d.DLG_TYPE_MODAL_RESIZEABLE, defaultw=300, defaulth=200)

if __name__ == "__main__":
    main()

Cheers,
Maxime.

This can be done by sending directly the correct message:

bc = c4d.BaseContainer(c4d.IDM_SELECTALL)
self.SendMessage(10000, bc)  # 10000 is the ID of the MultiLineEditText gadget

And here a complete example:

import c4d

class ExampleDialog(c4d.gui.GeDialog):

    def CreateLayout(self):
        self.SetTitle("This is an example Dialog")

        my_text = """jfsdskdhsdfsd
        fsd
        fsd
        sdf
        sddsf
"""
        self.AddMultiLineEditText(10000, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, style=c4d.DR_MULTILINE_MONOSPACED | c4d.DR_MULTILINE_HIGHLIGHTLINE | c4d.DR_MULTILINE_READONLY)

        self.SetString(10000, my_text)

        # Creates a Ok and Cancel Button
        self.AddDlgGroup(c4d.DLG_OK | c4d.DLG_CANCEL)

        return True

    def Command(self, messageId, bc):
        if messageId == c4d.DLG_OK:
            bc = c4d.BaseContainer(c4d.IDM_SELECTALL)
            self.SendMessage(10000, bc)
            
            return True
        elif messageId == c4d.DLG_CANCEL:
            self.Close()

        return True


def main():
    dlg = ExampleDialog()

    dlg.Open(c4d.DLG_TYPE_MODAL_RESIZEABLE, defaultw=300, defaulth=200)

if __name__ == "__main__":
    main()

Cheers,
Maxime.

@m_adam You know so much! Thank you for the example code.

You have helped me so much, Maxime, particularly on my current project. I am very grateful!