Hello,
as my posts have caused some confusion in the past, here first a short version of my problem:
Clicking the âxâ at the window corner of a TGTextEditor emits a CloseWindow() signal, but closing via File->Exit menu or by pressing the exit button on the toolbar unfortunately doesnât.
And now the details about what Iâm trying to do with these signals, because maybe there is a better way.
In my gui application you can add some output to a TGTextEditor (fEditor) which will pop up when EditorWrite() is called. Since, this can be done repeatedly and I donât want multiple editors to pop up, I have to monitor whether âfEditorâ exists already or not. However, this is only working partially.
My approach - I am open for better ideas - relies on the TGTextEditor::CloseWindow() signal. When the signal is emitted I set fEditor = 0 and when I want to write to fEditor I check if( fEditor == 0 ). ( See below and also in the little test app attached to this post. EditorWrite() can be called via the histogram drop-down menu. )
void MyGui::EditorWrite(){
if( fEditor == 0 ){
fEditor = new TGTextEditor();
fEditor->Connect(fEditor, "CloseWindow()", "MyGui", this, "EditorClosed()");
}
fEditor->AddText( new TGText("Added some text to the editor") );
}
void MyGui::EditorClosed(){
std::cout << "Inside EditorClosed()" << std::endl;
delete fEditor;
fEditor = 0;
}
Like mentioned above, this works pretty well if I close the editor via the little âxâ in the window corner - the CloseWindow() signal is emitted as confirmed by the âInside EditorClosed()â message. Whenever I use the File->Exit menu or the toolbar exit button, there is no signal and thus no message and no reset of fEditor. The reason might be the variable âfExitingâ in the TGTExtEditor::CloseWindow() source, maybe Bertrand knows.
Anyway, is there a way to work around that, e.g. like blocking the not working exit methods, so the editor can only be closed by the âxâ? Or maybe something completely different?
Thanks
Greg
MyGui.tar.gz (1.3 KB)