Ruby,草图添加另一个文本框到输出框

时间:2016-12-23 13:59:58

标签: ruby sketchup

我正在通过ruby sketchup控制台运行此代码。

            prompts = ["Stair Width", "Travel","Tread Thickness","Total Height","Riser Thickness","Stringer Width","Stringer Thickness","Top Hanger Thickness","Customer","Customer Address","Top Hanger Nose","Stair Nose","Flight"]
    defaults = [36.0,0.00,1.0,0.00,0.5,11.25,1.25,0.5,"My Builder", "234 Jimmys Street","Yes","Yes","Main"]
    list=["","","","","","","","","","", "Yes|No","Yes|No"]

    input = UI.inputbox prompts, defaults,list, "Stair Info"
        a,b,c,d,e,f,g,h,i,j,k,l,m=input
        cst=i.to_s
        adr=j.to_s
ent = Sketchup.active_model.entities
    tr=(d/8.0).ceil
    rise=d/tr
    run=((b-(1+h))/(tr-1))

我想在" Total Height"旁边添加一个额外的文本框。输入框并在退出" Total Height"时使其等于tr输入框。 有没有办法在Total Height输入框旁边添加一个文本框,并使其等于" tr"一旦离开Total Height输入框?

enter image description here

1 个答案:

答案 0 :(得分:0)

如果要控制布局,则需要创建自己的对话框。 public class CheckBoxTableCell<S, T> extends TableCell<S, T> { private final CheckBox checkBox; private ObservableValue<T> ov; public CheckBoxTableCell() { this.checkBox = new CheckBox(); this.checkBox.setAlignment(Pos.CENTER); setAlignment(Pos.CENTER); setGraphic(checkBox); } @Override public void updateItem(T item, boolean empty) { super.updateItem(item, empty); if (empty) { setText(null); setGraphic(null); } else { setGraphic(checkBox); if (ov instanceof BooleanProperty) { checkBox.selectedProperty().unbindBidirectional((BooleanProperty) ov); } ov = getTableColumn().getCellObservableValue(getIndex()); if (ov instanceof BooleanProperty) { checkBox.selectedProperty().bindBidirectional((BooleanProperty) ov); } } } } 并未对此进行任何控制。

SketchUp中另一个Ruby替代方法是使用UI.inputbox(来自SketchUp 2017及更高版本; http://ruby.sketchup.com/UI/HtmlDialog.html)它使用嵌入式Chromium控件。如果您需要支持旧版SketchUp,可以使用UI::HtmlDialog; http://ruby.sketchup.com/UI/WebDialog.htmlUI::WebDialog使用可用的系统浏览器(Windows上的IE,Mac上的Safari / WebKit)。您无法确定用户已安装的版本。

有关WebDialog的一些有用信息,请访问:https://github.com/thomthom/sketchup-webdialogs-the-lost-manual/wiki

您也可以尝试SKUI项目,它是WebDialog之上的包装器,它允许您仅使用Ruby代码创建简单的UI小部件:https://github.com/thomthom/SKUI(它抽象出HTML / CSS代码)