Adding Buttons to Tags



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 02/03/2011 at 18:45, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   12 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Does anyone have an example of adding a button to a tag?
    I think I have the external files(.res & .str) set up correctly. But I'm confused about what to put in the .cpp file.

    I can make check boxes all day long like this:

    Bool myTag::Init(GeListNode *node)  
    {      
      BaseTag *tag = (BaseTag* )node; // Assigns a variable to the tag's node  
      BaseContainer *data = tag->GetDataInstance(); // Assigns a variable to that node's container  
      data->SetBool(MYBOX,FALSE); //Sets the checkbox to disabled by default when tag is created  
        
      data->SetBool(MYBUTTON,FALSE); //trying to set up a button but this just creates another checkbox  
      
        
     //This code sets up the expression priority options   
      GeData d;  
      if (node->GetParameter(DescLevel(EXPRESSION_PRIORITY),d,DESCFLAGS_GET_0))  
    {  
      PriorityData *pd = (PriorityData* )d.GetCustomDataType(CUSTOMGUI_PRIORITY_DATA);  
      if (pd) pd->SetPriorityValue(PRIORITYVALUE_CAMERADEPENDENT,GeData(FALSE));  
      node->SetParameter(DescLevel(EXPRESSION_PRIORITY),d,DESCFLAGS_SET_0);  
    }  
      
     return TRUE;  
    } 
    

    I only know how to add gadgets using dialogs and the GeDialog class in Coffee.
    But I'm trying to learn how to add buttons and sliders to the tag itself. Similar to the "Delete Tag" button on the Phong tab on objects.

    -ScottA



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 02/03/2011 at 19:10, xxxxxxxx wrote:

    I usually place buttons in the Message() function.  Like this.

      
    //MESSAGE  
    //====================================================//  
    Bool PlanetXObject::Message(GeListNode *node, LONG type, void *t_data){  
      
      BaseObject *op = (BaseObject* )node;  
      BaseContainer *bc = op->GetDataInstance();  
      
      switch (type){  
      
          case MSG_DESCRIPTION_COMMAND:{  
                
              DescriptionCommand *dc = (DescriptionCommand* ) t_data;  
              if(!dc)return FALSE;  
            
              //LOAD PRESET  
              if (dc->id==(DescID)PLANETX_GENERAL_LOAD_PRESET)  
              {  
                  //Set the Filename  
                  Filename file;  
                  Filename dir = GeGetPluginPath() + "presets/files";  
                  file.SetDirectory(dir);  
                    
                  if(file.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_LOAD, "Load Preset")){  
      
                      bc->SetString(PXG_CURRENT_PRESET_TEXT, file.GetFileString());  
                    
                      LoadPreset(node, file);  
                  }  
                  else{  
                      GePrint("NO FILE CHOSEN");  
                  }  
              }  
      
              //SAVE PRESET  
              if (dc->id==(DescID)PLANETX_GENERAL_SAVE_PRESET)  
              {  
                  SavePreset(node);  
              }  
          }  
            
          //Rotate  
          case MSG_DESCRIPTION_CHECKUPDATE:  
              return RotatePlanet(static_cast<BaseObject*>(node), static_cast<GeListNode*>(node));  
      }  
      
      return TRUE;  
    }  
    

    Sorry many of my samples are coming from PXG right  now because that is what I have been updating lately.  :)

    Hope that helps.

    Shawn



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 02/03/2011 at 19:31, xxxxxxxx wrote:

    Thanks Shawn,
    But I'm having a hard time stripping out what I need from that example.

    I'm guessing that this is the button:
    if (dc->id==(DescID)PLANETX_GENERAL_LOAD_PRESET)

    And then it's using a .res file that has this in it?:
    PLANETX_GENERAL_LOAD_PRESET

    I'm too new at this to understand how to edit your example to make it work on my tag. 😕

    -ScottA



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/03/2011 at 02:18, xxxxxxxx wrote:

    Clicked buttons result in a MSG_DESCRIPTION_COMMAND message. Their IDs are passed along as well.

    Here is an example of the Message() method for a tag with two buttons.

      
    Bool MyTag::Message(GeListNode *node, LONG type, void *data)  
    {  
      switch (type)  
      {  
          // MSG_DESCRIPTION_COMMAND is send when button is clicked  
          case MSG_DESCRIPTION_COMMAND:  
          {  
              // data contains the description ID of the button  
              DescriptionCommand *dc = (DescriptionCommand* )data;  
                
              // get the ID of the button  
              LONG button = dc->id[0].id;  
                
              // check for different button IDs  
              switch (button)  
              {  
                  case MYTAG_BUTTON1:  
                      // do something  
                      break;  
                  case MYTAG_BUTTON2:  
                      // do something  
                      break;  
              }  
          }  
      }  
      
      return TRUE;  
    }  
    

    And here are the according resource files.

    Tmytag.h

      
    #ifndef _Tmytag_H_  
    #define _Tmytag_H_  
      
    enum  
    {  
     MYTAG_BUTTON1    = 1000,  
     MYTAG_BUTTON2  
    };  
      
    #endif  
    

    Tmytag.res

      
    CONTAINER Tmytag  
    {  
      NAME Tmytag;  
      INCLUDE Texpression;  
      
      GROUP ID_TAGPROPERTIES  
      {  
          BUTTON MYTAG_BUTTON1 { }  
          BUTTON MYTAG_BUTTON2 { }  
      }  
    }  
    

    Tmytag.str

      
    STRINGTABLE Tmytag  
    {  
      Tmytag            "My Tag";  
      MYTAG_BUTTON1    "Button1";  
      MYTAG_BUTTON2    "Button2";  
    }  
    

    Hope this helps.

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/03/2011 at 08:32, xxxxxxxx wrote:

    That's perfect Matthias.
    Exactly what I was looking for. Thanks.

    Just one other question about this if I may?
    When I try to edit the layout of the buttons. It keeps crashing C4D.
    In the SDK it says to use LAYOUTGROUP like this:

    GROUP  
      {  
      LAYOUTGROUP; COLUMNS 2;      
      
      GROUP ID_TAGPROPERTIES  
      {  
          BOOL MYBOX { }          
          BUTTON MYTAG_BUTTON1 {}  
          BUTTON MYTAG_BUTTON2 {}  
          //BUTTON MYTAG_BUTTON2 {HIDDEN;} //This works. Use this to hide the button if desired  
      }  
      
      }
    

    That works and doesn't crash C4D. But it also doesn't actually change anything yet.
    -If I try to use something like this:  BORDERSIZE 8,8,8,8;  C4D crashes
    -If I try to use something like this:  BUTTON MYTAG_BUTTON1 {ALIGN_RIGHT}  C4D crashes

    So I'm left wondering what's the point of using a LAYOUTGROUP if it won't let me add any parameters to change the layout. Except for ANIM ON | OFF | MIX; ,` OPEN;`` , HIDDEN;?

    Am I using this wrong?

    -ScottA
    `



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/03/2011 at 08:42, xxxxxxxx wrote:

    Descriptions only accept certain layout flags, like the number of columns. Alignments etc. don't work. You do your layout through groups. Go through some descriptions resource files to see what is possible. In general I recommend to study the SDK examples.

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/03/2011 at 09:40, xxxxxxxx wrote:

    I am putting the layout formatting like this: BORDERSIZE 8,8,8,8;  inside of the groups(not the GROUP ID group). But it's still crashing on me.

    I'll dig through the SDK examples and see if I can figure out what I'm doing wrong.
    I just wanted to make sure I wasn't trying to do something that I wasn't allowed to do in the first place.

    Thanks for the help. 👍
    -ScottA



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/03/2011 at 12:55, xxxxxxxx wrote:

    For Description resources you can't use Dialog resources and formatting.  In the R12 SDK documentation, check out "Description resource".



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/03/2011 at 15:44, xxxxxxxx wrote:

    Thanks Robert,

    I figured that out today after an hour of beating my head against my keyboard.😂
    Anytime I see the word "Dialog" used in the SDK. I have to tell myself that this is not going to work for attributes attached to objects and tags(Descriptions).

    I'm actually doing pretty good so far thanks to the template that Matthias posted.
    I've got my tag set up with buttons, sliders, value fields,  TextBoxes, and even a Multi-Selection button. So I will have a nice working reference file to use later on.

    The only problem I'm having now is trying to figure out how to control things like the size of a text box field. So it doesn't extend all the way across the attribute window.
    There's a section in the SDK called "Descriptions" that lists out a lot of flag options. But I don't see any option listed in there that would help me out.

    For example :
    STRING MYTEXTBOX { } // Works fine..But goes all the way across the AM window
    But
    STRING MYTEXTBOX { SCALEH 10;} // Crashes C4D

    The only controls I can find for controlling the layout of Descriptions without crashing C4D is using COLUMNS in combination with groups. Which is pretty limited.
    But I'm still looking around for more options at this point.
    I did find a nice example file in the resource->res->description folder called  "olight.res" that has a ton of descriptions in it to learn from.

    -ScottA



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 04/03/2011 at 01:17, xxxxxxxx wrote:

    As mentioned formating flags don't work for descriptions :)

    cheers,
    Matthias


Log in to reply