135 me.lastChangeTime =
time;
136 me.dragScrollTimer =
time;
137 if (ascii >= 32 && ascii != 127)
139 me.enterText(me,
chr(ascii));
141 me.applyButton.disabled =
false;
160 me.cursorPos =
strlen(me.text);
163 if (me.cursorPos > 0)
168 me.applyButton.disabled =
false;
181 me.applyButton.disabled =
false;
190 float cursorPosInWidths, totalSizeInWidths;
193 me.mouseDrag(me, me.dragScrollPos);
196 me.recalcPositionWithText(me, me.text);
198 me.focusable = !me.disabled;
204 if (me.focused && !me.disabled)
210 me.cursorPos =
bound(0, me.cursorPos,
strlen(me.text));
214 if (me.dragScrollTimer <
time)
216 float save = me.scrollPos;
217 me.scrollPos =
bound(cursorPosInWidths - (0.875 - me.keepspaceLeft - me.keepspaceRight), me.scrollPos, cursorPosInWidths - 0.125);
218 if (me.scrollPos != save)
219 me.dragScrollTimer =
time + 0.2;
221 me.scrollPos =
min(me.scrollPos, totalSizeInWidths - (1 - me.keepspaceRight - me.keepspaceLeft));
222 me.scrollPos =
max(0, me.scrollPos);
225 if (me.editColorCodes)
227 vector p = me.realOrigin -
eX * me.scrollPos;
228 vector theColor =
'1 1 1';
231 for (
int i = 0, n =
strlen(me.text); i < n; ++i)
237 string ch2 =
substring(me.text, i + 1, 1);
239 float fill_alpha = 0.4;
242 if (me.cursorPos > i && me.cursorPos <= i + 2)
244 draw_Fill(p,
eX * w +
eY * me.realFontSize.y,
'1 1 1', fill_alpha);
245 draw_Text(p +
eX * 0.25 * w,
"^", me.realFontSize, theColor, theAlpha, 0);
252 case 0: theColor =
'0 0 0';
break;
253 case 1: theColor =
'1 0 0';
break;
254 case 2: theColor =
'0 1 0';
break;
255 case 3: theColor =
'1 1 0';
break;
256 case 4: theColor =
'0 0 1';
break;
257 case 5: theColor =
'0 1 1';
break;
258 case 6: theColor =
'1 0 1';
break;
259 case 7: theColor =
'1 1 1';
break;
260 case 8: theColor =
'1 1 1'; theAlpha = 0.5;
break;
261 case 9: theColor =
'0.5 0.5 0.5';
break;
263 if (me.cursorPos > i && me.cursorPos <= i + 2)
265 draw_Fill(p,
eX * w +
eY * me.realFontSize.y,
'1 1 1', fill_alpha);
275 theTempColor.x = component / 15;
280 theTempColor.y = component / 15;
285 theTempColor.z = component / 15;
286 theColor = theTempColor;
289 if (me.cursorPos > i && me.cursorPos <= i + 5)
291 draw_Fill(p,
eX * w +
eY * me.realFontSize.y,
'1 1 1', fill_alpha);
323 draw_Fill(p,
eX * w +
eY * me.realFontSize.y,
'1 1 1', fill_alpha);
330 draw_Text(p, ch, me.realFontSize, theColor, theAlpha, 0);
335 draw_Text(me.realOrigin -
eX * me.scrollPos, me.text, me.realFontSize,
'1 1 1', 1, 0);
337 if (!me.focused || (
time - me.lastChangeTime) <
floor(
time - me.lastChangeTime) + 0.5)
338 draw_Text(me.realOrigin +
eX * (cursorPosInWidths - me.scrollPos), CURSOR, me.realFontSize,
'1 1 1', 1, 0);
342 if (me.enableClearButton && me.text !=
"")
344 if (me.focused && me.cb_pressed)
345 draw_Picture(
eX * (1 + me.cb_offset - me.cb_width),
strcat(me.cb_src,
"_c"),
eX * me.cb_width +
eY, me.cb_colorC, 1);
346 else if (me.focused && me.cb_focused)
347 draw_Picture(
eX * (1 + me.cb_offset - me.cb_width),
strcat(me.cb_src,
"_f"),
eX * me.cb_width +
eY, me.cb_colorF, 1);
349 draw_Picture(
eX * (1 + me.cb_offset - me.cb_width),
strcat(me.cb_src,
"_n"),
eX * me.cb_width +
eY, me.cb_color, 1);