scide: LookupDialog - redo lookup on classes after partial lookup
[supercollider.git] / SCClassLibrary / Common / GUI / osx / scide_scapp / Base / SCViews2.sc
blobba40af54cfc804a31c07a9565142fcfa329dd22e
1 SCTextFieldOld : SCNumberBoxOld {
3         *viewClass { ^SCNumberBoxOld }
5         defaultKeyDownAction { arg key, modifiers, unicode;
6                 if(unicode == 0,{ ^this });
7                 // standard keydown
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
12                         });
13                         ^this
14                 });
15                 if (key == 127.asAscii, { // delete key
16                         if(keyString.notNil,{
17                                 if(keyString.size > 1,{
18                                         keyString = keyString.copyRange(0,keyString.size - 2);
19                                 },{
20                                         keyString = String.new;
21                                 });
22                                 this.string = keyString;
23                                 this.stringColor = typingColor;
24                         },{
25                                 keyString = String.new;
26                                 this.string = keyString;
27                                 this.stringColor = typingColor;
28                         });
29                         ^this
30                 });
31                 if (keyString.isNil, {
32                         keyString = this.string;
33                         this.stringColor = typingColor;
34                 });
35                 keyString = keyString.add(key);
36                 this.string = keyString;
37         }
38         string_ { arg s; super.string = s.as(String); }
40         defaultGetDrag {
41                 ^this.string
42         }
43         defaultCanReceiveDrag {
44                 ^currentDrag.respondsTo(\asString)
45         }
46         defaultReceiveDrag {
47                 this.valueAction = currentDrag;
48         }
55 SCAutoCompleteTextField : SCTextField {
57         var <possibles,charIndex=0,searchIndex=0;
59         possibles_ { arg list;
60                 possibles = list.sort;
61         }
63         keyDownAction { arg view, key, modifiers, unicode;
64                 var keyChar;
65                 // standard keydown
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;
71                         });
72                         ^this
73                 });
74                 if (key == 127.asAscii, { // delete key
75                         if(keyString.notNil,{
76                                 if(keyString.size > 1,{
77                                         keyString = keyString.copyRange(0,charIndex = keyString.size - 2);
78                                         // research on next tab
79                                         searchIndex = 0;
80                                 },{
81                                         keyString = String.new;
82                                         charIndex = searchIndex = 0;
83                                 });
84                                 view.string = keyString.asString;
85                                 view.stringColor = Color.red;
86                         },{
87                                 keyString = String.new;
88                                 view.string = keyString;
89                                 view.stringColor = Color.red;
90                                 charIndex = searchIndex = 0;
91                         });
92                         ^this
93                 });
94                 if (keyString.isNil, {
95                         keyString = view.string;
96                         view.stringColor = Color.red;
97                         searchIndex = charIndex = 0;
98                 });
99                 if(key == $\t) { // tab
100                         // step through
101                         keyChar = keyString.at(charIndex);
102                         for(searchIndex,possibles.size - 1,{ arg i;
103                                 var candidate;
104                                 candidate = possibles.at(i);
105                                 while({ candidate.at(charIndex) == keyChar }, {
106                                         bestMatch = candidate;
107                                         charIndex = charIndex + 1;
108                                 });
109                                 //should spot gone past it...
110                         });
111                 keyString = keyString.add(key);
112                 view.string = keyString;
113         }
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);
126         }
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);
129         }
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);
132         }