Skip to content

Commit b3096c3

Browse files
committed
Provide TButton const for class name
1 parent e57f798 commit b3096c3

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

modules/draw.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import { clTStreamerInfoList } from './io.mjs';
99
import { clTBranchFunc } from './tree.mjs';
1010
import { BasePainter, compressSVG, _loadJSDOM } from './base/BasePainter.mjs';
1111
import { ObjectPainter, cleanup, drawRawText, getElementCanvPainter, getElementMainPainter } from './base/ObjectPainter.mjs';
12-
import { TPadPainter } from './gpad/TPadPainter.mjs';
12+
import { TPadPainter, clTButton } from './gpad/TPadPainter.mjs';
13+
1314

1415
// v7 namespace prefix
1516
const _v7 = 'ROOT::Experimental::';
@@ -32,7 +33,7 @@ const drawFuncs = { lst: [
3233
{ name: clTCanvas, icon: 'img_canvas', class: () => import('./gpad/TCanvasPainter.mjs').then(h => h.TCanvasPainter), opt: ';grid;gridx;gridy;tick;tickx;ticky;log;logx;logy;logz', expand_item: 'fPrimitives' },
3334
{ name: clTPad, icon: 'img_canvas', class: () => import('./gpad/TPadPainter.mjs').then(h => h.TPadPainter), opt: ';grid;gridx;gridy;tick;tickx;ticky;log;logx;logy;logz', expand_item: 'fPrimitives' },
3435
{ name: 'TSlider', icon: 'img_canvas', class: () => import('./gpad/TPadPainter.mjs').then(h => h.TPadPainter) },
35-
{ name: 'TButton', icon: 'img_canvas', class: () => import('./gpad/TPadPainter.mjs').then(h => h.TPadPainter) },
36+
{ name: clTButton, icon: 'img_canvas', class: () => import('./gpad/TPadPainter.mjs').then(h => h.TPadPainter) },
3637
{ name: 'TFrame', icon: 'img_frame', draw: () => import('./gpad/TCanvasPainter.mjs').then(h => h.drawTFrame) },
3738
{ name: clTPave, icon: 'img_pavetext', class: () => import('./hist/TPavePainter.mjs').then(h => h.TPavePainter) },
3839
{ name: clTPaveText, sameas: clTPave },

modules/gpad/TCanvasPainter.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { GridDisplay, getHPainter } from '../gui/display.mjs';
55
import { cleanup, resize, selectActivePad, EAxisBits } from '../base/ObjectPainter.mjs';
66
import { TAxisPainter } from './TAxisPainter.mjs';
77
import { TFramePainter } from './TFramePainter.mjs';
8-
import { TPadPainter } from './TPadPainter.mjs';
8+
import { TPadPainter, clTButton } from './TPadPainter.mjs';
99

1010

1111
/** @summary direct draw of TFrame object,
@@ -621,7 +621,7 @@ class TCanvasPainter extends TPadPainter {
621621
selectActivePad(pad_painter, obj_painter, click_pos) {
622622
if (!this.snapid || !pad_painter) return; // only interactive canvas
623623

624-
let arg = null, ischanged = false, is_button = pad_painter.matchObjectType('TButton');
624+
let arg = null, ischanged = false, is_button = pad_painter.matchObjectType(clTButton);
625625

626626
if (pad_painter.snapid && this._websocket)
627627
arg = { _typename: 'TWebPadClick', padid: pad_painter.snapid.toString(), objid: '', x: -1, y: -1, dbl: false };

modules/gpad/TPadPainter.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { createMenu, closeMenu } from '../gui/menu.mjs';
1010
import { ToolbarIcons, registerForResize, saveFile } from '../gui/utils.mjs';
1111
import { BrowserLayout } from '../gui/display.mjs';
1212

13+
const clTButton = 'TButton';
1314

1415
function getButtonSize(handler, fact) {
1516
return Math.round((fact || 1) * (handler.iscan || !handler.has_canvas ? 16 : 12));
@@ -178,7 +179,7 @@ class TPadPainter extends ObjectPainter {
178179
if (!this.iscan && pad?.fName) {
179180
this.this_pad_name = pad.fName.replace(' ', '_'); // avoid empty symbol in pad name
180181
let regexp = new RegExp('^[A-Za-z][A-Za-z0-9_]*$');
181-
if (!regexp.test(this.this_pad_name) || ((this.this_pad_name == 'button') && (pad._typename == 'TButton')))
182+
if (!regexp.test(this.this_pad_name) || ((this.this_pad_name == 'button') && (pad._typename == clTButton)))
182183
this.this_pad_name = 'jsroot_pad_' + internals.id_counter++;
183184
}
184185
this.painters = []; // complete list of all painters in the pad
@@ -2126,4 +2127,4 @@ class TPadPainter extends ObjectPainter {
21262127

21272128
} // class TPadPainter
21282129

2129-
export { TPadPainter, PadButtonsHandler };
2130+
export { TPadPainter, PadButtonsHandler, clTButton };

0 commit comments

Comments
 (0)