Hi!
By default the ESC button terminates the application.
I want users to press ESC in order to pause the game.
Is it possible to replace default ESC behaviour?
Hi!
By default the ESC button terminates the application.
I want users to press ESC in order to pause the game.
Is it possible to replace default ESC behaviour?
There is a KEY_ESC constant that you can use to define a key_trigger in your input bindings. Or does ESC still close the button even though you have bound something to KEY_ESC?
I haven’t tested this but you might have to consume that input also. See http://www.defold.com/doc/input#_the_input_stack
Good point @sicher! It’s always good practice to consume input that has been dealt with.
I’m consuming the input by returning true
, and the app still quits:
function on_input(self, action_id, action)
print(action_id)
if action_id == constants.BACK and action.released then
-- go back
return true
end
end
It doesn’t even print the action_id
for that keypress.
Changing the associated key to KEY_BACKSPACE
makes everything work fine, so it’s not like I’ve forgotten to acquire focus or anything…
@britzl It looks like consuming the input doesn’t prevent ESC from closing the app. Any chance you could file a ticket for this?
Added an issue for this: DEF-1846