Set initial state in a bitmap button



  • On 16/10/2017 at 06:54, xxxxxxxx wrote:

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

    ---------
    Hello.

    I add a BitmapButton parameter in a NodeData's GetDDescription(....).

    Here is the code:

    const DescID* single_id = description->GetSingleDescID();
    DescID custom_button = DescLevel(param_id, CUSTOMDATATYPE_BITMAPBUTTON, 0);
    if (!single_id || custom_button.IsPartOf(*single_id, NULL)) {
    	BaseContainer cont = GetCustomDataTypeDefault(CUSTOMDATATYPE_BITMAPBUTTON);
    	cont.SetInt32(DESC_CUSTOMGUI, CUSTOMGUI_BITMAPBUTTON);
    	cont.SetBool(BITMAPBUTTON_BUTTON, true);
    	cont.SetBool(BITMAPBUTTON_TOGGLE, true);
    	if (resource_image_on > 0)
    		cont.SetInt32(BITMAPBUTTON_ICONID1, resource_image_on);
    	if (resource_image_off > 0)
    		cont.SetInt32(BITMAPBUTTON_ICONID2, resource_image_off);
    	description->SetParameter(custom_button, cont, group_id );
    }
    

    How can I set the initial state of that bitmap button ?

    Thank you.



  • On 16/10/2017 at 14:59, xxxxxxxx wrote:

    node->SetParameter(DescID(param_id), GeData(TRUE), DESCFLAGS_SET_0);
    

    or GeData(FALSE) for the other state.  Best to do this in Init() and not in GetDDescription().



  • On 17/10/2017 at 00:42, xxxxxxxx wrote:

    Hello.

    I can't use SetParameter in GetDDescription due to stack overflow issue (It is called again and again).
    Also, using BaseContainer to set the toggle button as bool causes a breakpoint in Cinema 4D.

    Thank you.



  • On 17/10/2017 at 07:26, xxxxxxxx wrote:

    Hello,

    as discussed here (get toggle state of BitmapButton) the toggle state is not part of the data type. So I guess one cannot set a default value.

    A toggle button is typically created by using a Boolean parameter with a CUSTOMGUI_BITMAPBOOL.

      
    const DescID booleanButtonID = DescID(DescLevel(9999, DTYPE_BOOL, 0));  
      
    BaseContainer settings = GetCustomDataTypeDefault(DTYPE_BOOL);  
    settings.SetBool(BITMAPBUTTON_BUTTON, true);  
    settings.SetBool(BITMAPBUTTON_TOGGLE, true);  
    settings.SetBool(BITMAPBUTTON_BORDER, BORDER_NONE);  
    settings.SetInt32(DESC_ANIMATE, DESC_ANIMATE_OFF);  
    settings.SetInt32(DESC_CUSTOMGUI, CUSTOMGUI_BITMAPBOOL);  
    settings.SetInt32(BITMAPBOOL_ACTIVE, 300000231);  
    settings.SetInt32(BITMAPBOOL_INACTIVE, 300000230);  
      
    desc->SetParameter(booleanButtonID, settings, ID_OBJECTPROPERTIES);  
    

    As Robert already said, the default value of a parameter should be set in the Init() function.

    best wishes,
    Sebastian


Log in to reply