Re: Self Installed Property: Access to the button that is being clicked?

Date : Fri, 22 Feb 2008 09:15:13 +0100
To : XSI(at)Softimage.COM
From : André Adam <a_adam(at)49games.de>
Subject : Re: Self Installed Property: Access to the button that is being clicked?
I've been down that route, and it's nasty. What I did was writing template functions and calling them as plain text (.toString()) into a regular _expression_ syntax to replace the name tokens for the final layout and logic. Something along the lines below:

Cheers!

    -André


    /*========================================================
      Logic
    ========================================================*/
    oPPGLayout.Language = "JScript";
    //Templates
    var sDoGlobalOnChangedAndInitTemplate = "PARAMGLOBAL.ReadOnly = !PARAMDOGLOBAL.Value;";
    var sbuttonCopyAnimationOnClickedTemplate = "if(PPGGLOBALCONTROL.Value){if(PPGGLOBALPARAMETER.isAnimated()){CopyAllAnimation2(PPGGLOBALPARAMETER, siFCurveSource);PasteAllAnimation(\"TARGETPARAMETER\");}else{RemoveAnimation(\"TARGETPARAMETER\");Dictionary.GetObject(\"TARGETPARAMETER\").Value = PPGGLOBALPARAMETER.Value;}}else{if(PPGPARAMETER.isAnimated()){CopyAllAnimation2(PPGPARAMETER, siFCurveSource);PasteAllAnimation(\"TARGETPARAMETER\");}else{RemoveAnimation(\"TARGETPARAMETER\");Dictionary.GetObject(\"TARGETPARAMETER\").Value = PPGPARAMETER.Value;}}";
    var sbuttonStoreAnimationOnClickedTemplate = "aTargets.push(\"TARGETRELPARAMETER\");if(PPGGLOBALCONTROL.Value){if(PPGGLOBALPARAMETER.isAnimated(siFCurveSource)){aSources.push(PPGGLOBALPARAMETER.Source);}else{aSources.push(PPGGLOBALPARAMETER.Value);}}else{if(PPGPARAMETER.isAnimated(siFCurveSource)){aSources.push(PPGPARAMETER.Source);}else{aSources.push(PPGPARAMETER.Value);}}aActive.push(true);";
    //****ppg logic
    var sOnInitLogic = OnInit.toString();
    var sOnInitBody = "";
    //MODEL LOOP
    for(var i=0; i<aAllSortedAndFormatted.length; i++){
      var oModel = aAllSortedAndFormatted[i][0];
      //****model logic
      var sbuttonCopyAnimationOnClickedLogic = fName_OnClicked.toString().replace("fName", "buttonCopyAnimation_" + oModel);
      var sbuttonCopyAnimationOnClickedBody = "";
      var sbuttonStoreAnimationOnClickedLogic = fStore_OnClicked.toString().replace("fStore", "buttonStoreAnimation_" + oModel).replace("MODEL", oModel).replace("ACTIONNAME", "paramActionName_" + oModel + ".Value").replace("START", "paramActionIn_" + oModel + ".Value").replace("END", "paramActionOut_" + oModel + ".Value");
      var sbuttonStoreAnimationOnClickedBody = "";
      //HEXGROUP LOOP
      var aModelGroups = aAllSortedAndFormatted[i][1];
      for(var j=0; j<aModelGroups.length; j++){
        var oGroup = aModelGroups[j][0];
        var sGroupString = (oGroup*256).toString(16).toUpperCase();
        var sParamDoGlobal = "paramDoGlobal_" + oModel + "_" + sGroupString;
        var sParamGlobal = "paramGlobal_" + oModel + "_" + sGroupString;
        //****group logic
        var sDoGlobalOnChangedLogic = fName_OnChanged.toString().replace("fName", sParamDoGlobal);
        var sDoGlobalOnChangedBody = sDoGlobalOnChangedAndInitTemplate.replace(/PARAMGLOBAL/g, sParamGlobal).replace(/PARAMDOGLOBAL/g, sParamDoGlobal);
        sOnInitBody = sOnInitBody + sDoGlobalOnChangedAndInitTemplate.replace(/PARAMGLOBAL/g, sParamGlobal).replace(/PARAMDOGLOBAL/g, sParamDoGlobal);
        //PARAMETER LOOP
        var aGroupIDs = aModelGroups[j];
        for(var k=1; k<aGroupIDs.length; k+=2){
          var oParameter = aGroupIDs[k+1];
          var sPPGParam = "param" + oParameter.FullName.replace(/\./g, "_").replace("_aa_BoneFlags_paramWeight", "");
          //****parameter logic
          sDoGlobalOnChangedBody = sDoGlobalOnChangedBody + sDoGlobalOnChangedAndInitTemplate.replace(/PARAMGLOBAL/g, sPPGParam).replace(/!PARAMDOGLOBAL/g, sParamDoGlobal);
          sOnInitBody = sOnInitBody + sDoGlobalOnChangedAndInitTemplate.replace(/PARAMGLOBAL/g, sPPGParam).replace(/!PARAMDOGLOBAL/g, sParamDoGlobal);
          sbuttonCopyAnimationOnClickedBody = sbuttonCopyAnimationOnClickedBody + sbuttonCopyAnimationOnClickedTemplate.replace(/PPGPARAMETER/g, sPPGParam).replace(/TARGETPARAMETER/g, oParameter.FullName).replace(/PPGGLOBALCONTROL/g, sParamDoGlobal).replace(/PPGGLOBALPARAMETER/g, sParamGlobal);
          sbuttonStoreAnimationOnClickedBody = sbuttonStoreAnimationOnClickedBody + sbuttonStoreAnimationOnClickedTemplate.replace(/TARGETRELPARAMETER/g, oParameter.FullName.slice(oModel.length+1)).replace(/PPGPARAMETER/g, sPPGParam).replace(/PPGGLOBALCONTROL/g, sParamDoGlobal).replace(/PPGGLOBALPARAMETER/g, sParamGlobal);
        }
        sDoGlobalOnChangedLogic = sDoGlobalOnChangedLogic.replace(/fBody;/g, sDoGlobalOnChangedBody);
        oPPGLayout.Logic = oPPGLayout.Logic + sDoGlobalOnChangedLogic;
      }
      sbuttonCopyAnimationOnClickedLogic = sbuttonCopyAnimationOnClickedLogic.replace(/fBody;/g, sbuttonCopyAnimationOnClickedBody);
      oPPGLayout.Logic = oPPGLayout.Logic + sbuttonCopyAnimationOnClickedLogic;
      sbuttonStoreAnimationOnClickedLogic = sbuttonStoreAnimationOnClickedLogic.replace(/fBody;/g, sbuttonStoreAnimationOnClickedBody);
      oPPGLayout.Logic = oPPGLayout.Logic + sbuttonStoreAnimationOnClickedLogic;
    }
    sOnInitLogic = sOnInitLogic.replace(/fBody;/g, sOnInitBody);
    oPPGLayout.Logic = oPPGLayout.Logic + sOnInitLogic;
    return oProp;
  }



Bradley Gabe wrote:

On Thu, Feb 21, 2008 at 11:43 AM, javier <javier.vdp(at)gmail.com> wrote:
well, the MyPropertyMyButton_OnClicked() performs whatever code you tell it. you want the label, with a little copy paste you can splatter it here.

If you want to build dynamic ppgs, what you do is you can have a generator pass the label onto both button and callback at the same time. No?  Too dirty for you?

It is indeed dynamic PPG's i'm after. Building them on the fly is pretty straightforward, as one can dynamically assign PPGLogic, but building a registered, self-installed PPG with dynamic buttons is proving to be a more difficult prospect.

I have attempted to do what you are describing here, have a function that can build other functions, but it hasn't been working. So far, the only way I can successfully get a button to trigger a command is if the command has been explicitly written with the button name... at least in Python. XSI may be more forgiving for jscript or vbscript for such things.


Within the callbacks you can allways get the PPG
Did you try PPG.Item("MyButton").Label
I havent tried it but sounds like it should do what you're after


Of course I can get the PPG, but what I am after is the lable of the button I just clicked. I figured, if I can't dynamically generate callback functions with the button names in them, I could at least write one hard-linked callback to one button name, then dynamically populate that button multiple times with label changes, and use the label as a switch in my one function.

If I can get a generator function to work, such that dynamically generated handlers will activate when their button is pressed, then there's no need to try this last technique.

Otherwise, I need to give up on this style of implementation, and build the tools as on the fly PPG's. :-)

-Brad
 


 

On Thu, Feb 21, 2008 at 8:57 AM, Bradley Gabe <withanar(at)gmail.com> wrote:
When developing a self installed property, within the callback handler for a button, is there any variable or pointer that provides a connection to that button?
For example, I'd like to LogMessage the label of a button when it is clicked without necessarily knowing what that label is. How could I do that? Is this even possible?




--- Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body: unsubscribe xsi

Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.