Skip to content
Kevin Harrison edited this page Jan 3, 2019 · 10 revisions

About

LÖVE-Nuklear is a native Lua module for building immediate mode GUIs for LÖVE games. It is a binding and back end for the Nuklear UI library. The binding makes use of Lua features such as optional arguments, tables, and dynamic typing to simplify the API.

Building

Windows binaries are included with every release.

The project uses CMake to build, and requires LuaJIT headers and libraries.

When fetching the code, you must also pull the required Nuklear code as a submodule. The simplest way to do this is to use:

$ git clone --recursive git@github.com:keharriso/love-nuklear.git

Quickstart

The following program shows the basic code to set up and use the library, including initialization and event handling:

local nuklear = require 'nuklear'

local ui

function love.load()
	love.keyboard.setKeyRepeat(true)
	ui = nuklear.newUI()
end

function love.update(dt)
	ui:frameBegin()
	-- Add UI code here
	ui:frameEnd()
end

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

function love.keypressed(key, scancode, isrepeat)
	if ui:keypressed(key, scancode, isrepeat) then
		return -- event consumed
	end
end

function love.keyreleased(key, scancode)
	if ui:keyreleased(key, scancode) then
		return -- event consumed
	end
end

function love.mousepressed(x, y, button, istouch, presses)
	if ui:mousepressed(x, y, button, istouch, presses) then
		return -- event consumed
	end
end

function love.mousereleased(x, y, button, istouch, presses)
	if ui:mousereleased(x, y, button, istouch, presses) then
		return -- event consumed
	end
end

function love.mousemoved(x, y, dx, dy, istouch)
	if ui:mousemoved(x, y, dx, dy, istouch) then
		return -- event consumed
	end
end

function love.textinput(text)
	if ui:textinput(text) then
		return -- event consumed
	end
end

function love.wheelmoved(x, y)
	if ui:wheelmoved(x, y) then
		return -- event consumed
	end
end

Put your UI code between the ui:frameBegin and ui:frameEnd calls. See the bundled example for a brief sample of what the library can do.

Documentation

See the Documentation page for a complete description of all available functions and style items.

Clone this wiki locally
You can’t perform that action at this time.