Copy link to clipboard
Copied
How to make the scrollbar work perfectly by showing the other buttons ("BT4" and "BT5") that were hidden inside the panel ??
That was what I did, however, without success:
var w = new Window("dialog");
var g = w.add ("group");
var panel = g.add("panel", [0,0,150,200]);
var sbar = g.add ("scrollbar", [0,0,20,200]);
sbar.onChanging = function () {$.writeln (sbar.value)}
var b1 = panel.add("button", [0,0,0,0], "BT1")
b1.location = [10, 12]
b1.size = [120, 50]
var b2 = panel.add("button", [0,0,0,0], "BT2")
b2.location = [10, 70]
b2.size = [120, 50]
var b3 = panel.add("button", [0,0,0,0], "BT3")
b3.location = [10, 128]
b3.size = [120, 50]
var b4 = panel.add("button", [0,0,0,0], "BT4")
b4.location = [10, 186]
b4.size = [120, 50]
var b5 = panel.add("button", [0,0,0,0], "BT5")
b5.location = [10, 245]
b5.size = [120, 50]
w.show();
All tips and help will be valid. Thank you in advance.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi MBA-2-rae. Thanks for the link! I have seen here this beautiful example, unfortunately I am very new to Scripting and have not been able to add my respective buttons in this script below. This is a bit tricky for my head. If please someone with more knowledge can show me replace the text options with individual buttons, I will be eternally grateful.
- var w = new Window('dialog');
- w.maximumSize.height = 300;
- var panel = w.add ('panel {alignChildren: "left"}');
- var scrollGroup = panel.add('group {orientation: "column", alignChildren: "left", spacing: 5}');
- var numItems = 500;
- var itemHeight, scrollGroupActualHeight;
- for (var i = 0; i < numItems; i++) {
- scrollGroup.add('statictext', undefined, 'Label ' + i);
- };
- var scrollBar = panel.add('scrollbar {stepdelta: 1}');
- scrollBar.onChanging = function () {
- var children = scrollGroup.children;
- var n;
- for (n=0; n<numItems; n++){
- children
.location.y = (n-this.value)*itemHeight; - };
- };
- //============================================
- w.onShow = function() {
- // Set various sizes and locations when the window is drawn
- panel.size.height = w.size.height-20;
- scrollBar.size.height = w.size.height-40;
- scrollBar.size.width = 20;
- scrollBar.location = [panel.size.width-30, 8];
- itemHeight = scrollGroup.children[0].size[1]+scrollGroup.spacing;
- scrollGroupActualHeight = panel.size[1] - panel.margins[1] - panel.margins[3]; // scrollGroup.size[1] is at the max value
- scrollBar.maxvalue = Math.ceil(numItems-(scrollGroupActualHeight/itemHeight));
- };
- w.show();