function init(self)
msg.post(".", "acquire_input_focus")
msg.post("proxy#overlay_proxy", "async_load")
end
function on_message(self, message_id, message, sender)
if message_id == hash("proxy_loaded") then
msg.post(sender, "enable")
msg.post(sender, "acquire_input_focus")
end
end
function on_input(self, action_id, action)
print("petselector::on_input")
return true
end
overlay.gui_script:
function init(self)
msg.post(".", "acquire_input_focus")
end
function on_input(self, action_id, action)
print("overlay::on_input")
return true
end
So, my question is, why are both on_input methods called when both return true? Shouldnât one interrupt the other?
Hmm. I think all scripts on all game objects on the same level in the hierarchy will get the input event. The return value form on_input() will only control if child game objects would get the input or not. So, if petselector would have had a childed game object with a script which also had acquired input focus it would not have received it if the petselector.script returned true in on_input(). Is this correct @sicher?
The parent-child relationship between game objects has absolutely nothing to do with input. In this particular case, I would imagine the problem lies in the collection-proxy border. The collection proxy acquires input after the petselector, and will therefore handle input before. You can test this by changing:
That will put the petselector at the top of the input stack again, and that should not pass on input to the collection proxy because of the âreturn trueâ in petselector.script.
So, changing the code as you wrote worked, as in it blocked the overlay.gui_scriptâs on_input() to be called.
Next question, can I do the opposite? So that the overlay script blocks the petselector scriptâs on_input(), or do I have to manually call ârelease_input_focusâ when the overlay is loaded?
You should be able to do that, but I think there is a bug in how the collection proxy deals with input consumption. It seems like it doesnât flag it as consumed for the outer collection, when itâs been consumed inside. @britzl would you mind adding an issue?