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

    Dialog Button executes code of 2 buttons [SOLVED]

    SDK Help
    0
    3
    259
    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.
    • H
      Helper
      last edited by

      On 19/06/2015 at 05:59, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R16 
      Platform:      Mac OSX  ; 
      Language(s) :     C++  ;

      ---------
      Hi,

      I have a commandData plugin working together with a messageData plugin.
      I have 2 buttons inside my GUI: DLG_BUTTON_1 and DLG_BUTTON_2.
      If you press on them, they both send a GePrint with their value inside ("Pressed button 1/2").

      The problem is, if I press the first button, GePrint prints them both.
      If I press the second button, GePrint only prints the second line.
      Here is my code:

        
      Bool MyDialog::Command(Int32 id, const BaseContainer &msg)  
      {  
        switch (id)  
        {  
            case DLG_BUTTON_1:  
            {  
                BaseDocument *doc = GetActiveDocument();  
                Int32 modelMode1 = doc->GetMode();  
                if (modelMode1 == Mmodel)  
                {  
                    GePrint("Pressed button 1");  
                }  
            }  
        
            case DLG_BUTTON_2:  
            {  
                BaseDocument *doc = GetActiveDocument();  
                Int32 modelMode2 = doc->GetMode();  
                if (modelMode2 == Mmodel)  
                {  
                    GePrint("Pressed button 2");  
                }  
            }  
        }  
        return true  
      }  
      

      Does somebody know why this is happening?
      And if I put code inside the if statement, will that be called 2 times as well?

      Thanks in advance for your help and time!
      Greetings,
      Casimir Smets

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 19/06/2015 at 06:13, xxxxxxxx wrote:

        Schoolboy error, you forgot to add the 'break' after each case.

        Steve

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 19/06/2015 at 07:03, xxxxxxxx wrote:

          Hi Steve,

          Hahaha, feeling a little bit stupid now! 😄
          I'm glad I've got it working now 😄

          Thanks for your answer!
          Greetings,
          Casimir Smets

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