Explanation of XML property callbacks

Can somebody shed light on XML property callbacks behavior? When exactly are they triggered

For example OnActivate states: Callback that is invoked when the property is activated.

That's not particularly helpful statement. With some testing I noticed that isvalid gets triggered on all fields whenever any change occurs or a callback is triggered. Similar with onactivate but it's not always calling them all.

I'm about to go through tedious trial-error method. Useful description would be highly appreciated!


What I actually need right now is what callback to use when I need action on list selection change but I don't want it to be triggered when other properties are modified. So far seems like I should use onvalidate.


There's about 17 callbacks but I suspect not all are valid in ACT Wizards?


Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭

    Hi @Pavel , I find that the easiest way to check when a callback is triggered is to get the callback to write something in the log file. For example use:

    <onupdate>Test1</onupdate

    and define Test1 as :

    def Test1(step):
        ExtAPI.Log.WriteMessage('Triggered onpudate Test 1')
    

    From what you described, `OnValidate` seems the good call.

    To comment on the main other callbacks:

    • IsValid: trigerred each time the property is modified, this callback is used to check that the property is valid (otherwise the field in a Wizard will stay red, and in Mechanical you will get an interrogation mark next to the custom object)
    • IsVisible: way to add or show a property to the user
    • OnInit: this is triggered when the extension is launched


  • Pavel
    Pavel Member Posts: 9
    5 Likes Name Dropper First Answer Photogenic
    **
    edited December 2022

    Hi @Pernelle Marone-Hitz,

    indeed, printing a message is what I ended up doing. A bit tedious but I ended up with better understanding about when different property callbacks are triggered. Some don't work as expected from the name. Many get triggered on any other property change. So for example that IsValid gets triggered when any property is changed even though nothing of the property with IsValid was accessed. Not exactly expected behavior. My findings shared below (tested in 22R2).

    You're right that OnValidate is most useful "act when this prop. changed. For changing visibility I sued to invent if statements within various callabacks but the IsVisible does quite well.