Make the documentWindow title "editable"?


#1

Is this possible, to make the DocumentWindow title editable, like any label ?

ALLBest


#2

Well, you could write a subclass that sticks a label on there, I guess. No reason why that wouldn’t work.


#3

yes this is exactly what i’ve done.
It is a good solution, but it overlays the window and dont let you move the window any longer.

That’s why i posted about worming mouse events from a component to the parent window…


#4

In other terms, my answer is better the following one :

Is the window title natively a label ?
If yes, i think i’ll go modify the juce src, or override some method(s).


#5

No, it’s painted by LookAndFeel::drawDocumentWindowTitleBar.


#6

[quote=“asair”]yes this is exactly what i’ve done.
It is a good solution, but it overlays the window and dont let you move the window any longer.
[/quote]

Don’t leave it there when you’ve done with it. A double click shows an editable label. When the label loses focus, or the user hits enter, it sets itself invisible, or is deleted.

That way you have full control of the title as normal, and an editor shows up only when invited.


#7

valley : of course, but i m not discussing about editor but simply label.

The perfect behaviour I’d like is the one :

  • simple mouseUp+mouseMove on a label in titleBar: moving the window
  • double click : editor

#8

You’re describing exactly what I described, no?

A label component works essentially the same way. It’s a static component that when clicked shows an editor.

A one row high editor component that is selectively displayed and hidden based on whether the user seems to be editing the title bar’s “label” is essentially what you’re asking for.

Unless I’m completely misunderstanding you, you seem to want to dogmatically force the title bar to be a label. Why? The side effects of doing so render this a highly inelegant solution.

By contrast, selectively showing an editor when, and only when, the user is modifying the title, allows the window to behave in the normal way right up until the user tries to give the title text ‘focus’. At that point, for a short period of time, a smallish section of the title bar will be a text editor. As soon as the user is done, the editor vanishes, the title bar text is updated, and normal window behaviour resumes.


#9

Yes , ok, sorry but I have not both english and concept understood…
Ok Voila, I understand.
I just have to manage an Editor on the title bar,
which (editor) is totally different and unattach to the “label” notion
(I though the contrary, but if I had read sources or doc a bit more…)

brief, thank you.


#10

Well it worked!
There is a little matter though,
to actualise the title name, i cannot benefit from “Label::wasTextEdited” event,
so I passed DocumentWindow::setName(Label::getText())into the paint method.


#11

You really shouldn’t do anything like that in your paint method… You might get away with it here, but it’s bad practice to do anything in there that changes a component’s properties.