0 Favourites

How do I really customize TextBox?

  • Hi everyone,

    I read the manual, researched the forums but couldn't find answers for two matters:

    1) the auto-scale property of TextBox doesn't fit the need I have for a custom size accordingly to different screen sizes. It is too small. If I set "font-size" to "2em", it will be too small for some devices but ideal for others. I think I could create some kind of condition based on the size of the WindowWidth, but there is no other way like putting "font-size" equal to "(WindowWidth/50)em" ? I tried this equation and others like "(Sprite.ImageWidth/20)em" but nothing worked. I think it has something to do with CSS, that I don't know, but then isn't there any way to get a custom font size for TextBox, other than Sprite Fonts?

    2) I have a TextBox to the player put his name on it, but even if I set the Keyboard "When any key is pressed" to set an Instance for it that sums 1 each time a key is pressed, nothing happens when the keyboard is pressed on the TextBox and so I can't check if the player have put a name at all so he can begin the game. The Instance only adds when I press Enter or Esc. Does someone knows what I am doing wrong and how to solve that?

    This is my first topic and I have solved other problems researching the forums and reading the manual, but those were above me. If you have any idea about how to deal with that, I would really appreciate the help.

    Thank you for your time reading and I wish you a nice day.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • for 1;

    try browser object

    and something like:

    Set CSS style "font-size" to Browser.ScreenWith/10&"px" [/code:3c89cf40]
    
    or compare Browser.ScreenWith
    if  Browser.ScreenWith is between 300&320 set font-size to.....etc
    
    for 2;
    try [b]len[/b] ..len(x) - return length of the string x
    
    system compare two values..len(TextBox.Text>0..
  • Hi korbaach,

    Thanks for the help. I'll still figure out the "font-size" but your help to problem 2 solved it completely.

    All the best to you,

    LuciusCD

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)