Hi,
I'm using a TButton in compiled code to unzoom a histogram. For some
reason, using the TButton's method string to unzoom the histogram through
the interpreter seems to be erasing the variables of the macro that's
displaying the TButton. (See "TButton push eats macro variables") To avoid
this problem but still use a TButton, I've subclassed TButton and overridden
the ExecuteEvent method as in the code below. This seems like a bad thing to
do. Is it?
Other than setting TButton's method string or subclassing TButton and
overriding ExecuteEvent, is there another way of responding to TButton
clicks? How likely is it that the code below will be broken by a future
version of ROOT? Are there plans to make TButtons emit a "Clicked()" signal
when they're clicked?
Thank you.
David
//fPad and fHistogram are member variables of TUnzoomHistogramButton.
void TUnzoomHistogramButton::ExecuteEvent(Int_t event, Int_t px, Int_t py)
{
//Respond to a user event. If the event corresponds to the user
//releasing mouse button 1, unzoom the histogram. Always pass
//the event up to this class's superclass (TButton).
if (event == kButton1Up) {
TAxis* xAxis = fHistogram->GetXaxis();
TAxis* yAxis = fHistogram->GetYaxis();
TAxis* zAxis = fHistogram->GetZaxis();
if (xAxis)
xAxis->UnZoom();
if (yAxis)
yAxis->UnZoom();
if (zAxis)
zAxis->UnZoom();
fPad->Modified();
}
TButton::ExecuteEvent(event, px, py);
}
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:49 MET