The GUI instance needs to be aware which element currently has focus.
Each element needs the following functions:
focus(bool)
Set this element to have input focus
Call the on_focus callback
has_focus()
return whether or not this element has focus
function Element:focus(f)
local focus = self:has_focus()
if focus and not f then
gui:set_focus(false)
elseif not focus and f then
gui:set_focus(self)
end
end
function Element:has_focus()
return gui._focus == self
end
I suppose for this to work, each element is going to need a handle of the GUI instance it belongs to!
The GUI instance needs to be aware which element currently has focus.
Each element needs the following functions:
I suppose for this to work, each element is going to need a handle of the GUI instance it belongs to!