Input and collection proxies (again) (DEF-1966) (SOLVED)

So, I have this project structure with a script and a collection proxy with a single object with a gui screen.

petselector.script:

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:

msg.post(sender, "acquire_input_focus")

to:

msg.post(sender, "acquire_input_focus")
msg.post(".", "acquire_input_focus")

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?

1 Like

Ah, of course. I knew that. Sorry for confusing things…

Was there a Jira added for this issue?

Ah, no, what’s the issue again? Not sure I understood what the problem was… :slight_smile:

No problem, I fixed it, DEF-1966

3 Likes

Fixed in Defold 1.2.137

1 Like