I can't create a text box

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
rusbelito
Prole
Posts: 8
Joined: Fri Jun 19, 2020 5:40 am

I can't create a text box

Post by rusbelito »

I'm trying to create a textbox. Try using some guides from previous forums but I think they are too old and outdated, download the SUIT .zip file from this place "https://suit.readthedocs.io/en/latest/index. html # suit-up "
since I saw that I had several additional tools in addition to the textbox but I have not been able to use or implement it, could you help me and learn how it works? or if there is simply a better way to create a textbox, thank you very much for your attention: 3
milon
Party member
Posts: 123
Joined: Thu Jan 18, 2018 9:14 pm

Re: I can't create a text box

Post by milon »

When you say textbox, do you mean the text you print onscreen for the player? Or are you talking about collecting text from the player?
User avatar
GVovkiv
Prole
Posts: 46
Joined: Fri Jan 15, 2021 7:29 am

Re: I can't create a text box

Post by GVovkiv »

I guess it's better to implement your own text box, because this library kinda bad
Here, simple example of how you can make your own textbox:

Code: Select all

local string = "Hello, World!"
local font = love.graphics.getFont()
local strw = font:getWidth(string)
local strh = font:getHeight(string)

function love.draw()
  local mx, my = love.mouse.getPosition()
  love.graphics.setColor(1, 1, 1, 0.2)
  love.graphics.rectangle("fill", mx, my, strw * 2, strh * 2)
  love.graphics.setColor(1, 1, 1, 1)
  love.graphics.print(string, mx + strw / 2, my + strh / 2)
end
togFox
Party member
Posts: 168
Joined: Sat Jan 30, 2021 9:46 am

Re: I can't create a text box

Post by togFox »

This has me thinking now - I've no idea how to collect a string of text via keyboard.
User avatar
Gunroar:Cannon()
Party member
Posts: 280
Joined: Thu Dec 10, 2020 1:57 am

Re: I can't create a text box

Post by Gunroar:Cannon() »

togFox wrote: Tue Mar 09, 2021 12:29 pm This has me thinking now - I've no idea how to collect a string of text via keyboard.
You could use love.keypressed(key,scancode,isrepeat) then collect the key which is the string character the user typed, or you could use love.textinput https://love2d.org/wiki/love.textinput
Check out Dust
me: I don't always code but when I do it's done flawlessly.
also me:

Code: Select all

 function Gunroar:Cannon()
    for x, enemy in ipairs(self.allEnemies) do
        self:Cannon(enemy)
    end
end

Code: Select all

Lua Error: [file Gunroar.lua]:18: C stack overflow
togFox
Party member
Posts: 168
Joined: Sat Jan 30, 2021 9:46 am

Re: I can't create a text box

Post by togFox »

Oh - I see some examples in that link. So many lines of code to emulate a text box.

Some days I really love love 2d and then some days ... Blah.

It's not enough to stop me though!
User avatar
pgimeno
Party member
Posts: 2614
Joined: Sun Oct 18, 2015 2:58 pm

Re: I can't create a text box

Post by pgimeno »

There's always love.window.showMessageBox though it's not suited for all uses.
rusbelito
Prole
Posts: 8
Joined: Fri Jun 19, 2020 5:40 am

Re: I can't create a text box

Post by rusbelito »

GVovkiv wrote: Mon Mar 08, 2021 7:16 pm I guess it's better to implement your own text box, because this library kinda bad
Here, simple example of how you can make your own textbox:

Code: Select all

local string = "Hello, World!"
local font = love.graphics.getFont()
local strw = font:getWidth(string)
local strh = font:getHeight(string)

function love.draw()
  local mx, my = love.mouse.getPosition()
  love.graphics.setColor(1, 1, 1, 0.2)
  love.graphics.rectangle("fill", mx, my, strw * 2, strh * 2)
  love.graphics.setColor(1, 1, 1, 1)
  love.graphics.print(string, mx + strw / 2, my + strh / 2)
end

Thank you very much, what I was trying was with an empty text box, capture the player's text and then show it in the same ucadro or in another thanks to a button and I think that with the example you showed me and with the text, imput that I let myself down "Gunroar: Cannon ()" I think I am dead to achieve it: 3, on the other hand I ask if love has ways to achieve the other functions that that suit library had such as putting a large text only in a certain box and putting a bar displacement
rusbelito
Prole
Posts: 8
Joined: Fri Jun 19, 2020 5:40 am

Re: I can't create a text box

Post by rusbelito »

Gunroar:Cannon() wrote: Tue Mar 09, 2021 12:59 pm
togFox wrote: Tue Mar 09, 2021 12:29 pm This has me thinking now - I've no idea how to collect a string of text via keyboard.
You could use love.keypressed(key,scancode,isrepeat) then collect the key which is the string character the user typed, or you could use love.textinput https://love2d.org/wiki/love.textinput

Thank you very much, I was able to combine the "love.textinput" that you told me with the code fragment that "GVovkiv" had given me above but I have a problem with the "love.text input" I capture and print very well but in the case of That the player makes a mistake when putting a "letter" key cannot erase or correct it, how can I correct this? or how do I correct an already written string
User avatar
darkfrei
Party member
Posts: 227
Joined: Sat Feb 08, 2020 11:09 pm

Re: I can't create a text box

Post by darkfrei »

How about this one?
viewtopic.php?t=3056
Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests