TextEditor


#1

I’ve encountered something weird when using TextEditor. For instance, the caret is not actually visible, though isCaretVisible returns true. And for second, I am not able to write anything in the editor.

This is the code:

text1.setBounds(140,200,100,100);
text1.setMultiLine (true);
text1.setReturnKeyStartsNewLine (true);
addAndMakeVisible(&text1);

Do I need to add anything else?


#2

setReadOnly (bool shouldBeReadOnly) ?


#3

From what I’ve gathered, the TextEditor is by default not read-only and isReadOnly is false, so I should be able to type…but nothing happens.


#4

The textEditor box is actually visible and you have clicked it to set it active, right?


#5

Yes, the textEditor is visible. The cursor for typing appears and I’ve tried typing, but to no effect. Should I add a Listener or something like that? I’ve got the ideea from a tutorial that it isn’t necesarry, maybe I’m wrong.


#6

No listeners required or anything like that. I have just tested this to check I’m not going mad and have no problem writing into a text editor created like you describe. Can’t think what you’re doing that is strange.

TIP: Setting the component’s size before adding it is a little wierd. Put the text1 setBounds() code in the parent component’s resized() method so it can respond to changes in the parent size.


#7

Ok, thanks for your input. I think there’s an issue with the caret, meaning I just set it to visible (though it’s visible by default) and it doesn’t appear. You were able to see it, I presume? Either way, thank you for your patience once again.


#8

Yes.

Post your entire parent component class source here . .


#9

Okay, here it goes:

class XAudioProcessorEditor : public AudioProcessorEditor
{

private: TextEditor text1;
public:
XAudioProcessorEditor (XAudioProcessor* ownerFilter);
~XAudioProcessorEditor();
void paint (Graphics& g);
};

and

XAudioProcessorEditor::XAudioProcessorEditor (XAudioProcessor* ownerFilter)
: AudioProcessorEditor (ownerFilter)

{
// This is where our plugin’s editor size is set.

setSize (700, 700);
addAndMakeVisible(&text1);
text1.setBounds(140,200,50,50);

}

I’ve tried a simplified version with the Introjucer and it’s the same, I can’t type and the caret is not visible. I can copy, cut, paste etc though.


#10

So you can select the text with mouse drag, right click in the box and get a popup menu?


#11

check the keyboard focus. `setWantsKeysboardFocus(true)’ on your component.


#12

I’ve got no text to select, but I can right click and get a pop-up menu, I can use paste, select all etc.

I’ve used something like this (I didn’t find setWants…):

and it returns false. Could this be the issue?


#13

Hugh made a tiny typo. Should be . .

setWantsKeyboardFocus(true)


#14

Thank you all for your replies!

Yeah, I found it, but still hasKeyboardFocus(true) returns false. That damned caret doesn’t appear.


#15

Have you made sure Plugin editor requires keyboard focus is ticked in your Introjucer project?

If so what host and plugin type are you building?

Have you tried the same set-up with a normal (non-plugin) app? Does that get text entry correctly?


#16

Yes, it worked! Thank you so much! Apparently [quote]some hosts can be a bit funny about keyboard focus[/quote] Awesome and thank you all for your answers and patience!