I have in my program a textentry, where you can put the name of the file to analyse, then when you push enter the program makes a plot.
But as I can see pushing enter is not intuitive for user, so I would like to put just by the TextEntry a TextButton like “Make a plot” with the same function as pressing enter. But then I get segmentation fault. What is wrong?
mframe->AddFrame(map1, new TGLayoutHints(kLHintsCenterX,BL,1,BU,BD));
TGTextButton *lm1 = new TGTextButton(mframe,"&load new \n map 1");
lm1->Connect(lm1,“Clicked()”,“MyMainFrame”,this,“SetMap1()”);
mframe->AddFrame(lm1, new TGLayoutHints(kLHintsCenterX,BL,BR,BU,BD));[/code]
What I can add is that SetMap1 takes text from ‘map1’ TextEntry.
It is hard to guess what’s going wrong with your code with so little information… Could you post a more complete part of your code (especially the slot method SetMap1()) or a working macro showing the problem?
You must not call destructor of the signal emitter in the slot.
This code:
fMain->Cleanup();
fMain->DeleteWindow();
Destroys the text entry and the button (and all other GUI elements)… It may work in some cases (e.g. the text entry), but will lead to a crash most of the time…