0 Replies Latest reply on Jun 7, 2016 7:56 PM by emadill

    EditText draw problem after layout update.

    emadill

      I'm creating a tool dialog with panel behaviour similar to the script below, however I'm getting artifacts when the "win.main" panel is modified. I can live with some but the dealbreaker is EditText objects don't render correctly after the panel is modified (be it "add_row" or the Scrollbar). They're selectable and text can be changed but they refuse to draw.

       

      Any suggestions? I'm running CC 2015.1.2 on Windows 10.

       

      var win = new Window(
          '''dialog{
              main:Panel{size:[300, 100], orientation:'row', alignment:['fill','fill'], alignChildren:['fill','fill'],
                  scrollgrp:Group{size:[250,80], orientation:'column', alignment:['left','top'], alignChildren:['fill','top']},
                  scrollbar:Scrollbar{size:[18,80] alignment:['right','top'], stepdelta:20, jumpdelta:50}
              },
              btnAdd:Button{text:'+'}
              }
          }'''
      );
      win.main.maximumSize.height = win.main.size.height;
      win.main.scrollgrp.minimumSize.height = win.main.scrollgrp.size.height;
      win.main.scrollbar.maximumSize.height = win.main.scrollbar.size.height;
      win.btnAdd.onClick = function () {
          add_row(win.main.scrollgrp);
          var children = win.main.scrollgrp.children;
          var scrollHeight = win.main.scrollgrp.size[1];
          scrollItemHeight = (children.length==0) ? 0 : children[0].size.height;
          win.main.scrollbar.maxvalue = Math.ceil(children.length-(scrollHeight/scrollItemHeight)-1);
          win.main.layout.layout(true);
      }
      function add_row(grp) {
          var group = grp.add("group");
          group.edit = group.add("EditText{size:[180,20]}");
          group.minus = group.add ("Button{text:'-'}");
          group.minus.onClick = sub_btn;
      }
      function sub_btn() {
          win.main.scrollgrp.remove(this.parent);
          win.main.layout.layout(true);
      }
      win.main.scrollbar.onChanging = function() {
          var children = win.main.scrollgrp.children;
          for(var i=0;i<children.length;i++){
              children[i].location.y = (i-this.value) * (children[i].size[1] + win.main.scrollgrp.spacing);
          }
      }
      add_row(win.main.scrollgrp);
      win.show ();