使用滑桿框
問題
您想要使用滑桿框來設定連續值,並且希望在移動滑桿時看到目前值。
解決方案
製作一個滑桿框和一個數位編輯框。 將腳本新增至滑桿框以更新數位編輯框。 將腳本新增至數位編輯框以更新滑桿框。
Eggs = 50;
Bacon = 50;
New Window( "Slider Display",
Border Box( Left( 10 ), Right( 10 ), top( 10 ), bottom( 10 ),
V List Box(
H List Box(
Text Box( "Eggs" ), // slider label
eggssb = Slider Box( 0, 100, Eggs, // slider script follows...
eggsnb << set( Eggs ); // update the value
// this example doesn't need any other interactive
// update. You could do some other work here, using
// the slider's value to change a graph, perhaps.
),
// text box to hold the slider's value...
eggsnb = Number Edit Box( Eggs, <<SETFUNCTION></SETFUNCTION>
Window with Slider and Edit boxes launches 2nd windowWindow with Slider and Edit boxes launches 2nd window帶有滑桿和編輯框的視窗啟動第二個視窗
討論
滑桿框和數位編輯框具有不同的行為。 滑桿框保留變數(例如雞蛋),並在滑桿移動時更新該變數。 滑桿回呼腳本可以直接使用該變數。 數位編輯框不會保留該變量,也不會更新它。 Eggs Number Edit 的回呼函數使用 <
您可以使用 TextBox 而不是 NumberEditBox 進行稍微簡單的變化,但您可能需要輸入精確的值,這對於滑桿來說很難。
也可以看看
http://www.jmp.com/support/help/Display_Boxes.shtml
幫助->書籍->JSL 文法參考
回覆:使用滑桿框您可以透過在滑桿框的腳本中四捨五入來獲得滑桿框以給出整數輸出:
Names Default To Here( 1 );
sliderValue = .6;
New Window("Slider", v list box(
text box("Slider box with integer output."),
slider box(
0,
10,
sliderValue,
sliderValue = round(sliderValue);
tb << Set Text( char( sliderValue ) )
),
tb = text box("")
));回覆:使用滑桿框謝謝
這解決了它:)
回覆:使用滑桿框謝謝!
你需要添加
gb<<INVAL></INVAL>
在兩個回調函數(用於雞蛋和培根數字編輯框)中通知 GraphBox 重繪它自己。 <<無效意味著無效並觸發重繪。 按照您編寫圖形框的方式,它將在重繪時獲取更改的資料。
回覆:使用滑桿框嗨克雷格
謝謝你的精彩貼文!
我稍微修改了你的腳本來說明我遇到的問題:
Eggs = 50;
Bacon = 50;
New Window( "Slider Display",
Border Box( Left( 10 ), Right( 10 ), top( 10 ), bottom( 10 ),
V List Box(
H List Box(
Text Box( "Eggs" ), // slider label
eggssb = Slider Box(
0,
100,
Eggs,
gb << Set Graphics Script( Marker( {Bacon, Eggs} ) );// slider script follows...
eggsnb << set( Eggs ); // update the value
// this example doesn't need any other interactive
// update. You could do some other work here, using
// the slider's value to change a graph, perhaps.
),
// text box to hold the slider's value...
eggsnb = Number Edit Box(
Eggs,
<<SETFUNCTION></SETFUNCTION>我的問題是,當我在數位編輯框中輸入數字時,圖表不會更新。 當我按下“Enter”鍵時,滑桿移動,但圖表沒有反映變化。 我嘗試了一些方法,但不知道如何解決它。
我希望你能幫忙?
BR
傑斯珀