GithubHelp home page GithubHelp logo

force-focus widgets about love-nuklear HOT 2 CLOSED

shakesoda avatar shakesoda commented on June 14, 2024
force-focus widgets

from love-nuklear.

Comments (2)

keharriso avatar keharriso commented on June 14, 2024

v2.2 lets you manually focus edit widgets. Unfortunately, I don't know of a way to create a chatbox -- you might want to post an issue to the Nuklear repository. Here is an example where enter focuses the edit box and commits the text if it's already focused:

local nuklear = require 'nuklear'

local ui

function love.load()
	ui = nuklear.newUI()
end

local active = false
local focus = false
local edit = {value = ''}
local messages = {}

function love.update(dt)
	ui:frameBegin()
	if ui:windowBegin('Focus Edit', 100, 100, 200, 100,
                          'border', 'title', 'movable') then
		ui:layoutRow('dynamic', 30, 1)
		if focus then
			ui:editFocus()
		end
		local state, changed = ui:edit('field', edit)
		active = state == 'active'
	end
	ui:windowEnd()
	ui:frameEnd()
	focus = false
end

function love.draw()
	ui:draw()
end

function love.keypressed(key, scancode, isrepeat)
	if key == 'return' then
		if active then
			table.insert(messages, edit.value)
			edit.value = ''
		else
			focus = true
		end
	end
	ui:keypressed(key, scancode, isrepeat)
end

function love.keyreleased(key, scancode)
	ui:keyreleased(key, scancode)
end

function love.mousepressed(x, y, button, istouch)
	ui:mousepressed(x, y, button, istouch)
end

function love.mousereleased(x, y, button, istouch)
	ui:mousereleased(x, y, button, istouch)
end

function love.mousemoved(x, y, dx, dy, istouch)
	ui:mousemoved(x, y, dx, dy, istouch)
end

function love.textinput(text)
	ui:textinput(text)
end

function love.wheelmoved(x, y)
	ui:wheelmoved(x, y)
end

from love-nuklear.

keharriso avatar keharriso commented on June 14, 2024

I am actually interested in this problem, so I went ahead and made an issue myself: vurtun/nuklear#781

from love-nuklear.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.