Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    How to use GeUserArea.DrawCustomButton()

    Cinema 4D SDK
    python sdk s26
    3
    5
    719
    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.
    • K
      kng_ito
      last edited by

      Hi,

      I looked at the Python SDK and could not find a detailed explanation, so let me ask two questions about DrawCustomButton().

      1. What is the 5th argument "ids" for?

      2. Is there a way to receive a message or something when I click on the button?

      Here is a simple script that opens a dialog with a UserArea and draws a button.
      It looks like just a rectangle is drawn, but I wish I could create an interactive button that can receive triggers with InputEvent() or Message().

      Thank you!

      import c4d
      
      class MyUserArea(c4d.gui.GeUserArea):
          def DrawMsg(self, x1, y1, x2, y2, msg_ref):
              # Initializes draw region
              self.OffScreenOn()
              self.SetClippingRegion(x1, y1, x2, y2)
              self.DrawRectangle(x1, y1, x2, y2)
              # Draws black background
              self.DrawSetPen(color=c4d.Vector(0))
              self.DrawRectangle(x1, y1, x2, y2)
              # Draws a button
              self.DrawCustomButton(x=20, y=20, w=80, h=40, ids=[0], nofill=False, focus=False)
      
      
      class MyDialog(c4d.gui.GeDialog):
          ua = MyUserArea()
          def CreateLayout(self):
              area = self.AddUserArea(id=0, flags=c4d.BFH_SCALEFIT|c4d.BFV_SCALEFIT)
              self.AttachUserArea(ua=self.ua, id=area)
              return True
      
      def main():
          dialog = MyDialog()
          dialog.Open(dlgtype=c4d.DLG_TYPE_MODAL, defaulth=200, defaultw=200)
      
      if __name__ == '__main__':
          main()
      

      2022-05-07 013200.png

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @kng_ito
        last edited by ferdinand

        Hello @kng_ito,

        Thank you for reaching out to us. Please excuse the long radio silence from our side. Your topic had the misfortune to be posted at the beginning of our company meeting on May the 6th and was then overlooked when we collected the accumulated topics on May the 16th once the meeting was over.

        I again want to apologize for this. If the topic is still relevant for you, we will be happy to answer it, but we would ask for a brief confirmation of continued relevance. Without such indication of continued relevance, we will consider this topic as solved and flag it as such by Friday, 17/06/2022.

        Thank you for your understanding,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • K
          kng_ito
          last edited by

          Hi @ferdinand ,
          I originally just asked out of curiosity, so no problem.
          As for the topic, I would like to know the solution for when the time comes to use this gadget in the future.
          Thank you.

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

            Hi @kng_ito, I jsut checked with the original dev that implemented this function and this function should have been marked as private as Ids are not stable, so we will not communicate on them and we will fix documentation to reflect that this method is private.

            With that's said I'm afraid , in any case it is not possible to automatically wire InputEvent, in a GeUserArea you have the drawing part and then it's up to you with pixel coordinate to know where the user clicked in InputEvent and then redraw your area accordingly.

            Cheers,
            Maxime.

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • K
              kng_ito
              last edited by

              Hi @m_adam ,
              It is unfortunate because I thought it would be useful if it were available, but I understand.
              Thank you for your prompt response!

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