I’ve got a label that lives in a parent component that’s not much wider. When I go to edit the text of the label, the TextEditor comes up offset 10 or so pixels to the left, and the first 5 or so characters of my Label are out of view on the left of the TextEditor.
I can compensate for this by overriding createEditorComponent() in my derived Label class, but what I’d rather do is have the editing look more as if it were in place, so the font height and location match the Label’s.
I thought perhaps I could do this by overriding showEditor() to adjust the location where the TextEditor appears, but the editor is a private variable. Is there another way to change the editor’s location, or could I lobby for making the editor protected, so it could be manipulated by derived classes?
maybe TextEditor:setIndents(0, 0) ?
I think the default for the TextEditor is to indent by around 5 pixels or so to allow for the border.
Right, I was going to try to call setBoundsIndent() on the editor after it was created, but I discovered that the editor is a private member of the Label class, so I can’t access the variable to call setBoundsIndent() or setIndent()
virtual TextEditor* YourSubClass::createEditorComponent ()
TextEditor* t = Label::createEditorComponent();
Thanks for the tip. For the record, the function is setIndents() not setIndent() in the Label class.
So, that changes the top and left hand size position, but it still leaves the TextEditor about 10 pixels shy on width in comparison to the Label. Is there a way to adjust that?
The other issue, I think, is that on the label the text is compressed, and the editor uses the uncompressed version of the text, so the text no longer fits in the same space. I’m guessing there’s no way to alter that, aside from increasing the width of the original label so it doesn’t have to use compressed text.
I believe the TextEditor is already sized when Label::createEditorComponent() returns, so just set your preferred size alongside the indents.
The other issue, I think, is that on the label the text is compressed, and the editor uses the uncompressed version of the text, so the text no longer fits in the same space. I’m guessing there’s no way to alter that, aside from increasing the width of the original label so it doesn’t have to use compressed text.[/quote]
That may well be a factor of the slightly smaller width of the TextEditor. Otherwise, re-implement the paint behaviour of the label such that it tracks with the TextEditor.