diff options
author | David McMackins II <contact@mcmackins.org> | 2017-08-30 06:41:24 -0500 |
---|---|---|
committer | David McMackins II <contact@mcmackins.org> | 2017-08-30 06:41:24 -0500 |
commit | 1162eec93e09dc1400d0c4e24e76b54cf918558b (patch) | |
tree | 3b4d4011f01e90300249e3992d7eeaf2bbdf8601 | |
parent | cd1a7c478f38b50d8e9c351d596b22877b87239f (diff) |
Control whether text input is enabled
-rw-r--r-- | gui.lua | 3 | ||||
-rw-r--r-- | state.lua | 3 |
2 files changed, 6 insertions, 0 deletions
@@ -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 @@ -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 |