Skip to content

Commit 7cc34bb

Browse files
committed
Use checkbox for some entries TH1/TH2 context menu
1 parent 693c211 commit 7cc34bb

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

scripts/JSRootPainter.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5263,31 +5263,29 @@
52635263
}
52645264
}
52655265

5266-
JSROOT.THistPainter.prototype.ToggleStat = function() {
5266+
JSROOT.THistPainter.prototype.ToggleStat = function(arg) {
52675267

52685268
var stat = this.FindStat();
5269-
52705269
if (stat == null) {
5271-
5270+
if (arg=='only-check') return false;
52725271
// when statbox created first time, one need to draw it
5273-
stat = this.CreateStat();
5274-
5272+
this.CreateStat();
52755273
this.Redraw();
5276-
5277-
return;
5274+
return true;
52785275
}
52795276

52805277
var statpainter = this.FindPainterFor(stat);
5281-
if (statpainter == null) {
5282-
alert("Did not found painter for existing stat??");
5283-
return;
5284-
}
5278+
if (statpainter == null) return false;
5279+
5280+
if (arg=='only-check') return statpainter.Enabled;
52855281

52865282
statpainter.Enabled = !statpainter.Enabled;
52875283

52885284
// when stat box is drawed, it always can be draw individualy while it
52895285
// should be last for colz RedrawPad is used
52905286
statpainter.Redraw();
5287+
5288+
return statpainter.Enabled;
52915289
}
52925290

52935291
JSROOT.THistPainter.prototype.IsAxisZoomed = function(axis) {
@@ -5907,7 +5905,6 @@
59075905
}
59085906

59095907
JSROOT.THistPainter.prototype.FillContextMenu = function(menu) {
5910-
59115908
if (this.zoom_xmin!=this.zoom_xmax)
59125909
menu.add("Unzoom X", function() { this.Unzoom(true, false, false); });
59135910
if (this.zoom_ymin!=this.zoom_ymax)
@@ -5916,13 +5913,12 @@
59165913
menu.add("Unzoom Z", function() { this.Unzoom(false, false, true); });
59175914
menu.add("Unzoom", function() { this.Unzoom(true, true, true); });
59185915

5919-
menu.add(JSROOT.gStyle.Tooltip ? "Disable tooltip" : "Enable tooltip", function() {
5916+
menu.add((JSROOT.gStyle.Tooltip ? "chk:" : "unk:") + "Show tooltips", function() {
59205917
JSROOT.gStyle.Tooltip = !JSROOT.gStyle.Tooltip;
59215918
this.RedrawPad();
59225919
});
59235920

59245921
if (this.options) {
5925-
59265922
var item = (this.options.Logx ? "chk:" : "unk:") + "SetLogx";
59275923

59285924
menu.add(item, function() { this.ToggleLog("x"); });
@@ -5936,7 +5932,7 @@
59365932
}
59375933
}
59385934
if (this.draw_content)
5939-
menu.add("Toggle stat", function() { this.ToggleStat(); });
5935+
menu.add((this.ToggleStat('only-check') ? "chk:" : "unk:") + "Show statbox", this.ToggleStat.bind(this));
59405936
}
59415937

59425938
// ======= TH1 painter================================================
@@ -6467,7 +6463,7 @@
64676463
JSROOT.TH1Painter.prototype.FillContextMenu = function(menu) {
64686464
JSROOT.THistPainter.prototype.FillContextMenu.call(this, menu);
64696465
if (this.draw_content)
6470-
menu.add("Auto zoom-in", function() { this.AutoZoom(); });
6466+
menu.add("Auto zoom-in", this.AutoZoom.bind(this));
64716467
}
64726468

64736469
JSROOT.TH1Painter.prototype.AutoZoom = function() {
@@ -6549,18 +6545,18 @@
65496545

65506546
JSROOT.TH2Painter.prototype.FillContextMenu = function(menu) {
65516547
JSROOT.THistPainter.prototype.FillContextMenu.call(this, menu);
6552-
menu.add("Auto zoom-in", this.AutoZoom().bind(this));
6553-
menu.add("Draw in 3D", this.Draw3D().bind(this));
6548+
menu.add("Auto zoom-in", this.AutoZoom.bind(this));
6549+
menu.add("Draw in 3D", this.Draw3D.bind(this));
65546550
menu.add("Toggle col", function() {
65556551
if (this.options.Color == 0)
65566552
this.options.Color = JSROOT.gStyle.DefaultCol;
65576553
else
6558-
this.options.Color = -1 * this.options.Color;
6554+
this.options.Color = - this.options.Color;
65596555
this.RedrawPad();
65606556
});
65616557

65626558
if (this.options.Color > 0)
6563-
menu.add("Toggle colz", this.ToggleColz().bind(this));
6559+
menu.add("Toggle colz", this.ToggleColz.bind(this));
65646560
}
65656561

65666562
JSROOT.TH2Painter.prototype.FindPalette = function(remove) {

0 commit comments

Comments
 (0)