How do I get user text input in RV?

I would like to give the user an option to manually enter a value that will get put into a source’s Transform2D, or a source’s group.rangeOffset parameters but I can’t figure out any way to get a text input to popup and get that input back.

In rvui.mu I see a Mu function called startTextEntryMode but I don’t see any equivalent function in python. And even if I were to call this Mu function from python, it doesn’t seem to have an option for just getting the input back so I can use it in python. Instead it seems to require a mu function that it will call on it’s own.

Thanks so much!

1 Like

Hi Jase,

Unfortunately functions in rvui.mu aren’t bound to Python. However, you can evaluate Mu in Python. If the only thing you need is to get user’s input, you can try something like this:

from rv import commands, rvtypes, runtime

class ExamplePackageMode(rvtypes.MinorMode):
    def __init__(self):
        rvtypes.MinorMode.__init__(self)

        ## Bind on event that you're sending
        globalBindings = [("example-event", self.processText, "Compute timecode into frames")]

    def Example(self, event): 
        runtime.eval("""
        {
            print("Defining\n");
            \: eventSender (void; string text)
            {
                print(text + ":Going\n");
                // Send event here to be captured by the other method
                let returnValue = sendInternalEvent("example-event", text);
                redraw();
            }

            startTextEntryMode(\: (string;) { print("Printing\n"); "Print Example: ";}, eventSender, false)(nil);
        }
        """, ['rvui', 'commands'])

    def processText(self, event):
        print "Event contents: ", event.contents()

def createMode():
    return ExamplePackageMode()

(In case formatting is kinda weird, here’s a .py file as well: exampleTextEntry.py (979 Bytes)

Hope this helps!
– Alexa

2 Likes