excessive / DOMy

A DOM-like GUI framework for the *awesome* LÖVE framework
Other
32 stars 2 forks source link

Element Focus #20

Closed karai17 closed 9 years ago

karai17 commented 9 years ago

The GUI instance needs to be aware which element currently has focus.

Each element needs the following functions:

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!

karai17 commented 9 years ago

Alright, this is in now.