mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 12:01:50 +00:00
fix input.add_callback
This commit is contained in:
parent
b59752bc84
commit
44b9e21d46
1 changed files with 4 additions and 5 deletions
|
|
@ -45,11 +45,6 @@ static int l_add_callback(lua::State* L) {
|
|||
handler = Events::keyCallbacks[key].add(actual_callback);
|
||||
}
|
||||
}
|
||||
|
||||
const auto& bind = Events::bindings.find(bindname);
|
||||
if (bind == Events::bindings.end()) {
|
||||
throw std::runtime_error("unknown binding " + util::quote(bindname));
|
||||
}
|
||||
auto callback = [=]() -> bool {
|
||||
if (!scripting::engine->getGUI()->isFocusCaught()) {
|
||||
return actual_callback();
|
||||
|
|
@ -57,6 +52,10 @@ static int l_add_callback(lua::State* L) {
|
|||
return false;
|
||||
};
|
||||
if (handler == nullptr) {
|
||||
const auto& bind = Events::bindings.find(bindname);
|
||||
if (bind == Events::bindings.end()) {
|
||||
throw std::runtime_error("unknown binding " + util::quote(bindname));
|
||||
}
|
||||
handler = bind->second.onactived.add(callback);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue