1 SCTextFieldOld : SCNumberBoxOld {
3 *viewClass { ^SCNumberBoxOld }
5 defaultKeyDownAction { arg key, modifiers, unicode;
6 if(unicode == 0,{ ^this });
8 if ((key == 3.asAscii) || (key == $\r) || (key == $\n), { // enter key
9 if (keyString.notNil,{ // no error on repeated enter
10 this.valueAction_(string);
11 keyString = nil;// restart editing
15 if (key == 127.asAscii, { // delete key
17 if(keyString.size > 1,{
18 keyString = keyString.copyRange(0,keyString.size - 2);
20 keyString = String.new;
22 this.string = keyString;
23 this.stringColor = typingColor;
25 keyString = String.new;
26 this.string = keyString;
27 this.stringColor = typingColor;
31 if (keyString.isNil, {
32 keyString = this.string;
33 this.stringColor = typingColor;
35 keyString = keyString.add(key);
36 this.string = keyString;
38 string_ { arg s; super.string = s.as(String); }
43 defaultCanReceiveDrag {
44 ^currentDrag.respondsTo(\asString)
47 this.valueAction = currentDrag;
55 SCAutoCompleteTextField : SCTextField {
57 var <possibles,charIndex=0,searchIndex=0;
59 possibles_ { arg list;
60 possibles = list.sort;
63 keyDownAction { arg view, key, modifiers, unicode;
66 if ((key == 3.asAscii) || (key == $\r) || (key == $\n), { // enter key
67 if (keyString.notNil,{ // no error on repeated enter
68 view.valueAction_(keyString);
69 keyString = nil;// restart editing
70 charIndex = searchIndex = 0;
74 if (key == 127.asAscii, { // delete key
76 if(keyString.size > 1,{
77 keyString = keyString.copyRange(0,charIndex = keyString.size - 2);
78 // research on next tab
81 keyString = String.new;
82 charIndex = searchIndex = 0;
84 view.string = keyString.asString;
85 view.stringColor = Color.red;
87 keyString = String.new;
88 view.string = keyString;
89 view.stringColor = Color.red;
90 charIndex = searchIndex = 0;
94 if (keyString.isNil, {
95 keyString = view.string;
96 view.stringColor = Color.red;
97 searchIndex = charIndex = 0;
99 if(key == $\t) { // tab
101 keyChar = keyString.at(charIndex);
102 for(searchIndex,possibles.size - 1,{ arg i;
104 candidate = possibles.at(i);
105 while({ candidate.at(charIndex) == keyChar }, {
106 bestMatch = candidate;
107 charIndex = charIndex + 1;
109 //should spot gone past it...
111 keyString = keyString.add(key);
112 view.string = keyString;
120 SCTabletView : SCView {
122 // var <>mouseDownAction,<>mouseUpAction;
124 mouseDown { arg x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount,absoluteZ,rotation;
125 mouseDownAction.value(this,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount,absoluteZ,rotation);
127 mouseUp { arg x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount,absoluteZ,rotation;
128 mouseUpAction.value(this,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount,absoluteZ,rotation);
130 doAction { arg x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount,absoluteZ,rotation;
131 action.value(this,x,y,pressure,tiltx,tilty,deviceID, buttonNumber,clickCount,absoluteZ,rotation);