How do I prevent user from moving TFrames?

Hello,
I would like to prevent TFrame from moving when selected with the mouse. TPad::SetEditable(kFALSE) does not quite do what I want: I still would like to interact with the TAxis with the mouse. Thank you.

Ed

Hi Ed,

TFrame->TWbox->TBox

You can prevent a TBox to be moved by setting the bit kCannotMove.
In case of a TFrame, do
gPad->FindObject(“TFrame”)->SetBit(TBox::kCannotMove)

Rene

Dear Rene,

I have exactly the same problem as Ed.
However, when I try your method, it only works if
gPad->FindObject(“TFrame”)->SetBit(TBox::kCannotMove)
is called interactively.
If I include the same code in a simple macro like:

{
   TCanvas *c1 = new TCanvas();
   c1->Divide(2,2);
   TH1F *a = new TH1F("a","",100,-10,10);
   a->FillRandom("gaus",10000);
   c->cd(1);
   gPad->GetFrame()->SetBit(TBox::kCannotMove); 
   a->Draw();
}

it does not work
Note that I replace gPad->FindObject(“TFrame”) by
gPad->GetFrame() because the first method crashes (NULL pointer).

What I am doing wrong? I am using ROOT 5.16.19 on Fedora Core 6.

Regards
Julien

Hi Julien,
call gPad->FindObject(“TFrame”)->SetBit(TBox::kCannotMove) after draw histo:

TCanvas *c1 = new TCanvas(); c1->Divide(2,2); TH1F *a = new TH1F("a","",100,-10,10); a->FillRandom("gaus",10000); c1->cd(1); a->Draw(); gPad->Update(); gPad->FindObject("TFrame")->SetBit(TBox::kCannotMove);Jan

Dear Jan,

It works. I have tried this sequence before but I put the Update after not before
finding the TFrame. It sounds logical anyway.

Thank you,.
Julien