1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

Asset - Extension Text Inputs - GM Studio 1

Discussion in 'Marketplace' started by Dragon47, Jul 27, 2016.

  1. Dragon47

    Dragon47 Member

    Joined:
    Jul 6, 2016
    Posts:
    179
    [​IMG]

    Demo: https://www.mediafir...qpb1o0g0uaztqrs


    Poor input boxes make your game look and feel unprofessional, and can ruin the important first impression of a player. But they're a pain to program properly. With this text input extension you can avoid dozens of hours of UI programming, and get high quality text inputs in an instant!

    This is the GM Studio 1 version of Text Inputs. Click here for the GM Studio 2 version.

    Features:
    • Singleline and multiline text input.
    • Horizontal and vertical text alignment.
    • Text selection (with mouse, shift, Ctrl + A, and doubleclick).
    • Text navigation (with mouse, arrow keys, home/end and page up/down with Ctrl functionality).
    • Copying, cutting and pasting.
    • Local undo/redo memory. Ctrl + Z and Ctrl + Y (as well as Ctrl + Shift + Z).
    • Delete and backspace with Ctrl functionality.
    • Supports both monospaced and variable-width fonts.
    • Custom cursor sprite and cursor styles.
    • Supports octothorps (#).
    • Commented and organized code.
    • Fast and optimized, made with efficiency in mind.
    • Logic and display separation.
    • Irrespective of room speed, dependent on delta_time (and easily convertable to other game loops if need be).
    • All GML.
    Marketplace link: https://marketplace....845/text-inputs

    Screenshots from marketplace:

    [​IMG]

    [​IMG]

    More:
    [​IMG]

    [​IMG]

    [​IMG]
     
    Last edited: Jul 8, 2017
  2. JeffJ

    JeffJ Member

    Joined:
    Jun 20, 2016
    Posts:
    322
    I've been using this a lot, and it's really good, but there is one feature I am sorely lacking: the ability to freely move around a field and have everything about it update realtime. Could this be added?
     
  3. Dragon47

    Dragon47 Member

    Joined:
    Jul 6, 2016
    Posts:
    179
    You can move a text field around with input_text_set_transformation. Here you can specify the position.
     
  4. JeffJ

    JeffJ Member

    Joined:
    Jun 20, 2016
    Posts:
    322
    I completely missed that script. Awesome!

    However, after moving it with that, I can no longer click in the field to activate it or write in it (where as using my own 'hack' making it jump to mouse coordinates did not give this result)
     
  5. Dragon47

    Dragon47 Member

    Joined:
    Jul 6, 2016
    Posts:
    179
    The collision boxes used for activating a text field in the asset's example is not really part of the actual text fields, it's just an example implementation for how to activate/deactivate text inputs. The extension on its own focuses on the text and not how its input is activated/deactivated. So if you want the collision box to move around with the text input, this has to be programmed on the user's side.
     
  6. JeffJ

    JeffJ Member

    Joined:
    Jun 20, 2016
    Posts:
    322
    Of course, I didn't think about that. That's what you get for trying to work when tired.

    Got it to work now. Thanks a lot!

    There are two more issues, one is minor, the other is a little more annoying.

    Minor: when you select a textfield that already has text in it, the cursor is not sent to the end of the text, but instead at the beginning as with an empty field. Is this by design? It seems counter intuitive.
    Not so minor: trying to copy text from an external source (such as notepad) and paste it into a text field in the program doesn't work, nor does it the other way around (copying text from a text field inside the program and pasting it into an external source)

    Otherwise this is perfect!
     
  7. Dragon47

    Dragon47 Member

    Joined:
    Jul 6, 2016
    Posts:
    179
    The cursor should be placed in the location you click with your mouse. If you click to the left of the text input it will be placed at the beginning, to the right it will be placed at the end, and in between, it should be placed between the two closest letters. See the example code.

    As for the other issue, the problem was that it was using the HTML5 version which only has local copying and pasting. I've updated the asset so that this works properly now, but haven't managed to upload it to the marketplace yet. I sent you a private message with the newest version.
     
  8. Dragon47

    Dragon47 Member

    Joined:
    Jul 6, 2016
    Posts:
    179
    Version 1.1.3 is now available on the marketplace.
     
  9. Coralium

    Coralium Guest

    I got this, but I'm having trouble making it work. Could you give an example on how to actually set up an input box? I've been trying to work it out from looking at the example, but so far no dice. (I'm a bit of a GML noob at the moment)
     
  10. Dragon47

    Dragon47 Member

    Joined:
    Jul 6, 2016
    Posts:
    179
    Take a look at the script called "GUIDE". It explains how to use the asset's scripts.
     
  11. Coralium

    Coralium Guest

    Well, I went for a walk, then came back and changed a couple of things and suddenly everything started working lol. Thanks for your time!
     
    Dragon47 likes this.
  12. Colcoction

    Colcoction Member

    Joined:
    Aug 14, 2016
    Posts:
    9
    This looks incredible. I have one question: can the text be stored (in a variable) and then loaded somehow? I'm thinking of using something like this for a project where the user can write information, save it, and then load it between play sessions. Would that be possible?
     
  13. Dragon47

    Dragon47 Member

    Joined:
    Jul 6, 2016
    Posts:
    179
    Yes, you can use input_text_get_text to get the content of an input field and input_text_set_text to set the input by code.
     
  14. JeffJ

    JeffJ Member

    Joined:
    Jun 20, 2016
    Posts:
    322
    When I save text from a multiline field with linebreaks to a file, the breaks are saved as "\n".
    How would I go about changing it so that it will instead save them as "#"?
     
  15. Dragon47

    Dragon47 Member

    Joined:
    Jul 6, 2016
    Posts:
    179
    The character "chr(10)" is used for new lines. If you do "string_replace_all(string_obtained_from_input_field, chr(10), "#");" I think it will work.
     
    JeffJ likes this.
  16. JeffJ

    JeffJ Member

    Joined:
    Jun 20, 2016
    Posts:
    322
    That totally did it. Thank you!
     
  17. Posho

    Posho Member

    Joined:
    Jul 23, 2016
    Posts:
    222
    Does anyone know how to make the '@' character work with this?
     
  18. Dragon47

    Dragon47 Member

    Joined:
    Jul 6, 2016
    Posts:
    179
    It works for me. I replied to your mail.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice