How to create a text edit UI control for strings

Hello

I have this use case where I need to create an editable text field in the UI. The content of the text field is an arbitrary string that the user provides. It is only used in the UI (the processor does not care about this value). It needs to be saved part of the state.

I am porting a Rack Extension to VST and this is what it looks like for the rack extension:

The “Audio Label A” is a free form text entry that the user can edit.

I tried to use the CTextEdit class which seems to be used for this purpose, but I just don’t see how to save it and restore its value. If I add a parameter for it in the controller like this

  parameters.addParameter(STR16 ("Audio Input Label A"), // title
                          STR16 (""), // units
                          0, // stepCount => 0 (unused)
                          0, // defaultNormalizedValue => 0 (unused)
                          0, // flags
                          ABSwitchParamID::kAudioInputLabelA, // tag
                          0, // unitID => not using units at this stage
                          STR16 ("LabelA")); // shortTitle

then it only accepts values between 0 and 1 because it seems that parameters are only representing values between 0 and 1 not strings.

Any help would be appreciated.

Thanks
Yan

Hi Yan,
parameters are for numeric representations. So you need to do something different. And it’s a little bit more involved than with simple parameters.
First of all you need a VST3EditDelegate which you give to the VST3Editor constructor.
Then you have two possibilities. First, the simpler one, is to use the VST3EditDelegate::verifyView method and check the views to find the CTextEdit control. If you have the control, you register a control listener (IControlListener) on it. On this listener object, you will get a valueChanged() call if the text in the text edit has changed. Then you can call the getText() method of the control and get the text.
The other method is to use a sub controller and use it to setup and listen to the edit control changes.

I hope this helps.

Arne

Thank you for the reply. I am going to give a shot to your VST3EditDelegate suggestion.

After much digging in the source code, I indeed realized that the again sample provided with the SDK uses a sub controller to extract the value of the text edit view in order to “send a message”. So if I am having issue with the VST3EditDelegate solution, I think I should be able to follow the again example at the very least…

So I think I should be able to make it work one way or another. I wished it was built-in :wink:

Thanks!
Yan