summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid McMackins II <contact@mcmackins.org>2017-08-30 06:41:24 -0500
committerDavid McMackins II <contact@mcmackins.org>2017-08-30 06:41:24 -0500
commit1162eec93e09dc1400d0c4e24e76b54cf918558b (patch)
tree3b4d4011f01e90300249e3992d7eeaf2bbdf8601
parentcd1a7c478f38b50d8e9c351d596b22877b87239f (diff)
Control whether text input is enabled
-rw-r--r--gui.lua3
-rw-r--r--state.lua3
2 files changed, 6 insertions, 0 deletions
diff --git a/gui.lua b/gui.lua
index 4f6ff71..3be7121 100644
--- a/gui.lua
+++ b/gui.lua
@@ -63,6 +63,7 @@ function GuiComponent:__init(x, y, w, h, bg, fg, state)
self.clicked = false
self.clicklisteners = {}
self.text = ''
+ self.usereditable = false
self.visible = false
end
@@ -152,9 +153,11 @@ TextField = class(GuiComponent)
function TextField:__init(x, y, w, h, bg, fg, state)
self._base.__init(self, x, y, w, h, bg, fg, state)
+ self.texteditable = true
self._placeholdertext = ''
self:addclicklistener(function()
self.state._activecomponent = self
+ love.keyboard.setTextInput(true)
end)
end
diff --git a/state.lua b/state.lua
index 3de1f33..86af1cc 100644
--- a/state.lua
+++ b/state.lua
@@ -116,6 +116,9 @@ function State:mousepressed(x, y, button)
return
end
end
+
+ self._activecomponent = nil -- user clicked away from text field
+ love.keyboard.setTextInput(false)
end
end