1 // value can be any object,
2 // display is asCompileString
6 *new { arg parent, bounds, label, action, initVal,
7 initAction=false, labelWidth=60, textWidth,
8 labelHeight=20, layout=\horz, gap, margin;
10 ^super.new.init(parent, bounds, label, action,
11 initVal, initAction, labelWidth, textWidth,
12 labelHeight, layout, gap, margin)
15 init { arg parentView, bounds, label, argAction, initVal,
16 initAction, labelWidth, argTextWidth,
17 labelHeight, argLayout, argGap, argMargin;
19 var labelBounds, textBounds, textSize;
20 var textWidth = argTextWidth;
23 this.prMakeMarginGap(parentView, argMargin, argGap);
28 bounds.isNil.if {bounds= 200@20};
30 // if no parent, then pop up window
31 # view,bounds = this.prMakeView( parentView,bounds);
33 textWidth.isNil.if{textWidth=140}{
34 labelWidth=bounds.width-textWidth; //override the labelWidth
35 // if (layout==\line2){unitWidth=bounds.width-textWidth}; //override the unitWidth
37 labelSize=labelWidth@labelHeight;
38 textSize = textWidth@labelHeight;
41 # labelBounds,textBounds
42 = this.prSubViewBounds(innerBounds, label.notNil);
46 label.notNil.if{ //only add a label if desired
47 labelView = GUI.staticText.new(view, labelBounds);
49 {labelView.align = \left;}
50 {labelView.align = \right;};
51 labelView.string = label;
54 // set view parameters and actions
55 initVal = initVal ? "";
58 textField = TextField(view, textBounds).resize_(2);
61 var newstr = textField.string;
62 var newval = try { newstr.interpret };
63 if (newval.notNil or: { newstr == "" }) {
64 this.valueAction_(newval);
66 // "EZText compile failed - reset to prev value.".postln;
67 textField.string = this.value.asCompileString;
72 this.valueAction = initVal;
82 textField.string = value.asCompileString;
86 labelView.notNil.if{labelView.font=font};
90 setColors { arg stringBackground, stringColor, textBackground, textStringColor,
91 textNormalColor, textTypingColor, background ;
93 stringBackground.notNil.if{
94 labelView.notNil.if{labelView.background_(stringBackground)};
96 stringColor.notNil.if{
97 labelView.notNil.if{labelView.stringColor_(stringColor)};
99 textBackground.notNil.if{
100 textField.background_(textBackground); };
101 textNormalColor.notNil.if{
102 textField.normalColor_(textNormalColor);};
104 textTypingColor.notNil.if{
105 textField.typingColor_(textTypingColor);};
106 textStringColor.notNil.if{
107 textField.stringColor_(textStringColor);};
108 background.notNil.if{
109 view.background=background;};
112 prSetViewParams { // sets resize and alignment for different layouts
115 labelView.notNil.if{labelView.resize_(2).align_(\left)};
116 textField.resize_(5);
120 labelView.resize_(4).align_(\right);
121 textField.resize_(5);
123 textField.resize_(5);
126 popUp.if{ view.resize_(2) };