Graphics

 View Only
  • 1.  OnSetText

    Posted 12-01-2014 20:44
    I see this event come up in the script editor for a Text Object, but it only seems to be raised when the scene is loaded.

    Is there a way I can get an event raised whenever the text in an xpTextObject is changed? This would be really useful.


  • 2.  RE: OnSetText

    Posted 12-01-2014 20:45
    Jim,

    It should be raised anytime the text is changed, but this does not apply to typing new text into the scene from layout mode. It will be called when the text is edited from the sequencer (and you subsequently press Enter to update the on-air scene) or when the text is linked to a widget or datalinq source and the value of the widget or datalinq changes.

    #XPression


  • 3.  RE: OnSetText

    Posted 12-01-2014 20:50
    Oh. 5.9.3130

    #XPression


  • 4.  RE: OnSetText

    Posted 12-01-2014 20:50
    I have it in a datalinq source, and changing the value in the source is not raising the event, as far as I can tell. Nothing I put in the OnSetText event happens unless I reload the scene.

    #XPression


  • 5.  RE: OnSetText

    Posted 12-01-2014 21:00
    Umm... ok, after some more extended testing, I'm finding that there IS an event being raised, but...

    The text value that I'm getting from the object is the text that USED to be there, not the text that has been set.

    Previous tests involved one try, and, upon not seeing any change, I assumed the event wasn't firing. What is happening, though, is that when I try to put the object's text into another field (just to see what happens), what I'm getting is the text that was just replaced, not the text that was just set.

    #XPression


  • 6.  RE: OnSetText

    Posted 12-01-2014 21:02
    The OnSetText script runs *before* the new text is applied. This allows the script to change the text that is about to be set. The new value of the text is passed into the script as the "Text" parameter to the script. If you do self.text you would get the old value, not the new one.

    If you can post your script we might be able to help you more.

    #XPression


  • 7.  RE: OnSetText

    Posted 12-01-2014 21:33
    OK, that gives me a better clue as to what's going on. I think I can deal with what I have. In fact, what I know now looks to be some good info. What I'm trying to do is this:

    We will have data coming in on an RSS feed, and it'll be updated about every second.

    When that happens, the new value will be placed somewhere, the old value someplace else, and we'll figure out a way to make some stuff happen on render.

    OnRender, when we need to, (or, if we can run an Animation Controller clip), we'll calculate a value for each frame that is the frame value * (1/30 of (newValue-oldValue) ) + oldValue. This will be rounded to the nearest integer, and placed in a field in the scene, so that the field text will "flip" from its old value to the new value. As it does that, we'll update the X-position of a slider using that text and Visual Logic. Since it'll happen at refresh rate, the slider should appear to move smoothly to the new position as the numbers flip.

    While we're on this, I guess it's be a great time to mention that some global variables would be a really useful feature.

    :-)

    #XPression


  • 8.  RE: OnSetText

    Posted 12-02-2014 04:27
    I think there was an example on this forum a while ago where a new datalinq value would go through a script that dynamically set keyframe values in an animation controller and would run the controller. This allowed bar graphs/polls to animate between different values when the new data was received. There wasn't any need for an OnRender script.

    #XPression


  • 9.  RE: OnSetText

    Posted 12-02-2014 18:44
    I did something similar to that, actually. When OnSetText was raised a field I put on the scene (and made invisible), I took both the Self.Text and Text (argument) values, calculated the difference, then made 30 _Global.Value variables, each of which contained a value of x* (Text - Self.Text)/30, where x is the intended frame number of a 1 second animation. I made a new Scene Director, and on it, in 1-frame increments put 30 copies of a script, all the same except for the variable called up. The scripts call the _Global.Value holding the incremental value for each frame, writes CInt(_Global.ValueX) to the display text field, and also writes the double value to another invisible text field. THAT field is connected via Visual Logic to the slider indicator quad's x-position, taking into account adjustments for that indicator's actual position and range. Once the values are calculated, the script for the input field gets the dedicated Scene Director and runs it.

    I'll have to give the method you're citing a try. It sounds simpler, actually. If I can do a CInt in Visual Logic, or find another way to do rounding (It's easy, actually), I could just set the start and end x-positions of the slider and hook those values through the rounding process, and display that in the text field. Come to think of it, it probably WOULD be easier.

    #XPression


  • 10.  RE: OnSetText

    Posted 12-02-2014 19:06
    Bleh. Now that I think of it, it's NOT easier. I do a couple of range and scaling calculations to move the slider position, and I'd have to undo all of that to get back the values for the text field. Maybe works, maybe not.

    #XPression