TextEditor - drag to scroll in read only mode? (iOS)

Thought I’d post this in macOS / iOS as it’s really something I’d specifically like to do in iOS.

I’m using a TextEditor set to read only to display help text. User expectations are to be able to drag to scroll the text, as opposed to grabbing a scrollbar thumb.

The current TextEditor behaviour is to select text when dragging which I currently hide by setting the highlight colour to transparent.

I’m struggling to come up with an approach to do this cleanly, i.e. not a hack… I know the TextEditor viewport isn’t exposed (although that was requested a while back…), but after looking at how mouseDrag is handled in a viewport, I got pretty confused pretty quickly! (doesn’t take much).

Plus I get the feeling that somehow trying to re-direct the TextEditor mouse drag event to the viewport DragToScrollListener will end in tears… (edit: it did)

Anyone else had a go at this? I can’t be the only one surely :slight_smile:

Have you tried making the text editor a static size, big enough to display all the text, but not added as a child. Then wrapping this in a ViewPort?

I should have posted an example, I have just been testing, while this does work, the text is still selected on touch, so you may still need to set the colours.

NewProjectAudioProcessorEditor::NewProjectAudioProcessorEditor (NewProjectAudioProcessor& p)
    : AudioProcessorEditor (&p), audioProcessor (p)
{
    textEditor.setSize(200,400);
    textEditor.setMultiLine(true);
    textEditor.setText("This is some demo text! \n to see if \n scrolling within \n a viewport \n works \n I am having trouble \n finding enough \n words to say \n to make this text need scrolling \n but i shall try.");
    textEditor.setReadOnly(true);
   
    addAndMakeVisible(viewPort);
    viewPort.setViewedComponent(&textEditor);
    
    setSize (400, 300);
}

void NewProjectAudioProcessorEditor::resized()
{
    viewPort.setSize(200,200);
    viewPort.setCentrePosition(getBounds().getCentre());
}

In the header, I also added

   juce::TextEditor textEditor;
   juce::Viewport viewPort;

Many thanks @Curlymorphic - I shall give that a try! Looks like a neat solution, much obliged! -Rob