ATTRIB(InputBox, forbiddenCharacters, string, "")
ATTRIB(InputBox, color, vector, '1 1 1')
ATTRIB(InputBox, colorF, vector, '1 1 1')
- ATTRIB(InputBox, maxLength, float, 255)
+ ATTRIB(InputBox, maxLength, float, 255) // if negative, it counts bytes, not chars
ENDCLASS(InputBox)
void InputBox_Clear_Click(entity btn, entity me);
#endif
for(i = 0; i < strlen(ch); ++i)
if(strstrofs(me.forbiddenCharacters, substring(ch, i, 1), 0) > -1)
return;
- if(strlen(ch) + strlen(me.text) > me.maxLength)
- return;
+ if(me.maxLength > 0)
+ {
+ if(strlen(ch) + strlen(me.text) > me.maxLength)
+ return;
+ }
+ else if(me.maxLength < 0)
+ {
+ if(u8_strsize(ch) + u8_strsize(me.text) > -me.maxLength)
+ return;
+ }
me.setText(me, strcat(substring(me.text, 0, me.cursorPos), ch, substring(me.text, me.cursorPos, strlen(me.text) - me.cursorPos)));
me.cursorPos += strlen(ch);
}
if(me.pressed)
me.mouseDrag(me, me.dragScrollPos); // simulate mouseDrag event
+ if(me.recalcPos)
+ me.recalcPositionWithText(me, me.text);
+
me.focusable = !me.disabled;
if(me.disabled)
draw_alpha *= me.disabledAlpha;
draw_Text(p, substring(me.text, i, 2), me.realFontSize, '1 1 1', theAlpha, 0);
}
}
- /*else if(ch2 == "a") // ^a found
- {
- draw_Fill(p, eX * w + eY * me.realFontSize_y, '1 1 1', 0.5);
- draw_Text(p, substring(me.text, i, 2), me.realFontSize, theColor, 0.8, 0);
-
- component = str2chr(me.text, i+2);
- if (component >= '0' && component <= '9')
- component = component - '0';
- else if (component >= 'a' && component <= 'f')
- component = component - 87;
- else if (component >= 'A' && component <= 'F')
- component = component - 55;
- else
- component = -1;
-
- if (component >= 0) // ^ah found
- {
- // FIX ME: overflow here
- if (component == 20 && theVariableAlpha <= 0.97)
- theVariableAlpha = theVariableAlpha + 0.0625;
- else if (component == 30 && theVariableAlpha >= 0.03)
- theVariableAlpha = theVariableAlpha - 0.0625;
- else
- theVariableAlpha = component*0.0625;
-
- draw_Fill(p, eX * draw_TextWidth(substring(me.text, i, 3), 0, me.realFontSize) + eY * me.realFontSize_y, '0.8 0.8 0.8', 0.5);
- draw_Text(p, strcat(ch, ch2), me.realFontSize, theColor, 0.8, 0);
- }
- }*/
else
{
draw_Fill(p, eX * w + eY * me.realFontSize_y, '1 1 1', 0.5);
}
else
draw_Text(me.realOrigin - eX * me.scrollPos, me.text, me.realFontSize, '1 1 1', 1, 0);
- // skipping SUPER(InputBox).draw(me);
+
if(!me.focused || (time - me.lastChangeTime) < floor(time - me.lastChangeTime) + 0.5)
draw_Text(me.realOrigin + eX * (cursorPosInWidths - me.scrollPos), CURSOR, me.realFontSize, '1 1 1', 1, 0);
draw_ClearClip();
+
+ // skipping SUPER(InputBox).draw(me);
+ Item_draw(me);
}
void InputBox_showNotify(entity me)