Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Selecting the text in a GeDialog MultiLineEditText

    Cinema 4D SDK
    python
    2
    3
    400
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ?
      A Former User
      last edited by A Former User

      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!

      1 Reply Last reply Reply Quote 1
      • M
        m_adam
        last edited by

        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.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        ? 1 Reply Last reply Reply Quote 1
        • ?
          A Former User @m_adam
          last edited by

          @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!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post