JSL:滑块框设置值嗨,大家好,
以下是脚本索引中用于创建滑块框的代码:
Names Default To Here( 1 );
sliderValue = .6;
New Window( "Example",
Panel Box( "Slider Box",
tb = Text Box( "Value: " || Char( sliderValue ) ),
sb = Slider Box(
0,
1,
sliderValue,
tb << Set Text( "Value: " || Char( sliderValue ) )
)
)
);
如果运行此示例,则可以右键单击滑块以设置特定值:

假设我将其设置为0.8。 如果我这样做,则滑块会移动,但是与滑块关联的脚本无法执行。 也就是说,滑块上方的文本框不会更新。
问题1:为什么?
问题2:是否有其他方法可以将新值传输到文本框? 我试图将代码转换为使用“设置功能”消息,但这并不能解决问题。
我观察到,如果右键单击平台中的滑块(例如Custom Profiler)并设置“值”,则平台似乎可以正确响应(滑块和关联的“文本编辑框”都按预期移动),因此我可以知道有某种方法在JSL中做到这一点。 我只是不知道那是什么。
我在Mac上运行15.2.1 Pro。
麦可
脚本编写回复:JSL:滑块框设置值感谢您提供明确的示例和问题。 可以轻松地验证这是否是JMP 15中的错误(也许是早期版本)。 滑块的回调未在“设置值”上触发。
我还验证了我们已在即将发布的JMP 16版本中修复了该问题。
您可以在JSL中编写代码,这可能是一个棘手的解决方法,但是您看到它在内置平台中工作时,并不是通过JSL完成的。
回复:JSL:滑块框设置值我看不到解决方法,因为无法将表达式与“设置值”操作相关联。 这是原始脚本的一种变体,但是它也不起作用,因为在移动滑块时会调用它。
Names Default To Here( 1 );
sliderValue = .6;
New Window( "Example",
Panel Box( "Slider Box",
tb = Text Box( "Value: " || Char( sliderValue ) ),
Slider Box( 0, 1, sliderValue,
<< Set Function(
Function( { me },
tb << Set Text( "Value: " || Char( me << Get ) )
)
)
)
)
);回复:JSL:滑块框设置值这不能解决您确定脚本未触发的根本问题,但是我经常在该值旁边放置一个数字编辑框,并使用脚本来设置滑块的值。这样,如果有人要设置值,他们不太可能右键单击滑块,因为单击文本编辑框会更容易。这是同时包含这两种方法的一种方法,同时还可以在滑块移动或键入新值时运行某些功能:

Names Default To Here( 1 );
sliderValue = .6;
//Function that is called when either slider is moved or new value is typed in
dothisonchange = Function({val}, tb << Set Text( "Value: " || Char( val) ) );
New Window( "Example",
Panel Box( "Slider Box",
tb = Text Box( "Value: " || Char( sliderValue ) ),
h list box(
sb = Slider Box(
0,
1,
sliderValue,
//Set the number edit box and call the other function
neb << Set( sliderValue );
dothisonchange(sliderValue);
),
neb = Number Edit Box(
sliderValue,
3,
<< Set function( Function( {this},
sliderValue = this << Get;
//Set the slider and call the other function
sb << Set( sliderValue );
dothisonchange(sliderValue);
) )
)
)
)
);回复:JSL:滑块框设置值您也可以使用这种方法组合和连接号码编辑框和滑块框