root: Add a `has_key` and `has_button` functions.

This commit is contained in:
Emmanuel Lepage Vallee 2018-12-31 17:14:56 -05:00
parent 86d8ef3142
commit 93b90026e9
1 changed files with 8 additions and 0 deletions

View File

@ -106,6 +106,14 @@ for _, type_name in ipairs { "button", "key" } do
table.insert(removed, value)
end
capi.root["has_"..type_name] = function(item)
if not item["_is_capi_"..type_name] then
item = item[1]
end
return gtable.hasitem(capi.root["_"..prop_name](), item) ~= nil
end
assert(root[prop_name])
end