Hey Mike, all good to be new with scripting, thanks for coming to the forums to ask!
From what it’s sounding like; if you’re already setting a text object WITH the widget, you wouldn’t need to get the widget at all (since it’s setting the text object, so we have the info we would get from it anyway)
For future edification, to get a widget that’s within the same project as the scene, you’d use:
’ Depending on how you access the scene, whether it be via a text object (where the scene is called Scene)
’ or via the scene itself (where the scene is called Self), the reference below may change.
’ Check the parameters included with the method you’re using above the script entry box on the script.
dim myWidget as xpTextListWidget
Scene.Project.GetWidgetByName(“TheWidgetsName”, myWidget)
’ From there, once you’ve gotten the widget, all you need to do is use myWidget.Value to get whatever is typed in
dim dataWithinMyWidget as String = myWidget.Value
For our puposes, however, we can use the OnSetText Event. Whenever the Widget changes, the associated text object should change as well.
So with that said; our OnSetText gives us 2 crucial pieces of information: (1) “Self”, which is the TextObject that the event is happening on AS IT CURRENTLY STANDS and (2) “Text”, which is the string that is ABOUT TO BE SET on the Text object.
Granted, OnSetText is only going to run when the text is changed, so there may be an implication that every time the script is running, your weight class widget has changed, so you might not even need to truly compare. However, if we want to go ahead and verify that our weight class is changing, we can write a script like this:
’ Remember, Self is the text object as it stands historically, Text is the future text.
’ So here, we’re checking does “Self” (the object) “.Text” (the text property of the object) NOT EQUAL the upcoming “Text”?
If Not Self.Text.Equals(Text) Then
’ Do Stuff Here
End If