-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow.lua
More file actions
30 lines (26 loc) · 716 Bytes
/
window.lua
File metadata and controls
30 lines (26 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
gcb.window._handlers = {}
function gcb.window.registerCallbacks(win, callbacks)
if not win then return end
gcb.window._handlers[win] = {
onEvent = callbacks.onEvent,
onClose = callbacks.onClose
}
end
function gcb.window.unregisterCallbacks(win)
gcb.window._handlers[win] = nil
end
function gcb.onWindowEvent(win, id)
local handler = gcb.window._handlers[win]
if handler and type(handler.onEvent) == "function" then
handler.onEvent(win, id)
end
end
function gcb.onWindowClose(win)
local handler = gcb.window._handlers[win]
if handler and type(handler.onClose) == "function" then
handler.onClose(win)
else
gcb.window.destroy(win)
end
gcb.window._handlers[win] = nil
end