Enter Interprets Selection (TextView)

Hi all -

I am currently trying to create a GUI using a NodeProxy backbone.

I’d like to have slots for TextViews that could interpret their strings on specific indices for the established NodeProxy…something like the following…

(
var n = NodeProxy.audio(s, 2);
n.play;
 TextView(nil, Rect(800, 500, 300, 200))
.string_("{SinOsc.ar(440)}")
.enterInterpretsSelection_(true)
.action_({|x| n[0] = x.value;})
.front;
)

Obviously, the “action” method doesn’t work in this particular case… but I’m wondering if there is a way to get a similar outcome.

Thank you!

Just in case I wasn’t clear enough in the original post, I’d like to evaluate the function {SinOsc.ar(440)} on n[0]. I’m not entirely sure this is possible.

If I understand your requirement, enterInterpretsSelection isn’t what you want. This setting does not allow you access to the result of the interpreted text, so you can’t do anything further with it. It’s appropriate when you want to use a TextView as a code editor, but that isn’t your use case.

It sounds like you want your view’s action function to get the selection as a string, .interpret it, and then use the resulting value as you like.

hjh

1 Like