Text fields that can be changed?

Siluk03Siluk03 Posts: 4Member

Hello, everyone. I'm programming a software. On this software you should be able to add text fields among other things. How can I add text fields with a white background that can be moved and resized? Is this possible? Up to now I only worked with the TextEdit of Godot. Thanks a lot.

Comments

  • Siluk03Siluk03 Posts: 4Member

    Can anybody help me? I need the information for my end project at school. Thanks.

  • TwistedTwiglegTwistedTwigleg Posts: 2,125Admin

    With some scripting you can likely achieve what you are looking for. There are several different approaches you can take, but here is how I'd do it:

    • Make a scene with a Panel or ColorRect as the root node.
      • If using a panel, override the style to make it white. If using a ColorRect, it comes white by default.
    • Add how ever many TextFields you need as child nodes of the root node.
      • Make sure to setup their anchors! You may want to look into using Godot's Container nodes, like the VBox and HBox.
    • Add a script to the root node.
      • In the script, you will need to implement moving and resizing. Moving should, in theory, be relatively easy. I'd suggest taking a look at the Drag and Drop demo on the Godot demo repository.
      • Resizing is a little harder. You'll need to use code to detect if the mouse is at a certain position, wherever you want the resize gizmo to be, and then change the Rect size of the root node as the mouse moves. I haven't tried it myself, but I am positive it is doable with some work.
    • Profit!

    That said, there is the WindowDialog node that handles much of this for you. I haven't used it much myself, but if you want to use the WindowDialog node, I believe you will not need to write code for moving and resizing the root node. Here's how I think you could do it with the WindowDialog node:

    • Make a scene with a WindowDialog as the root node.
      • Override the style to make it white.
    • Add how ever many TextFields you need as child nodes of the root node.
      • Make sure to setup their anchors! You may want to look into using Godot's Container nodes, like the VBox and HBox.
    • Profit?

    That said, you will likely need to prototype and see what works and what doesn't.
    Hopefully this helps a bit, and welcome to the forums!

  • Siluk03Siluk03 Posts: 4Member

    Thanks a lot for your help. I'll try it out.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file