How to hide keyboard after native.showPopup("mail") call

Hello everyone!

Does anybody know how to hide keyboard after sending email?

OS: Android

Mail sent through Gmail app.

Here is my code:

[lua]

local options = {

to = { “test@gmail.com” },

subject = “Subject”,

isBodyHtml = true,

body = “<html><body></body></html>”

}

native.showPopup(“mail”, options)

[/lua]

Thanks!

P.S.

Also, is there any way to hide on-screen control buttons (android)?

https://docs.coronalabs.com/api/library/native/setKeyboardFocus.html

 native.setKeyboardFocus( nil )

Thanks for your reply!

Let me clarify - I do not understand at what time / in what place to call native.setKeyboardFocus( nil ).

native.showPopup(“mail”, options) doesn’t have listener for “mail”. Thats the problem.

I tried this code (and it works):

[lua]

local function checkKeyboard()   

native.setKeyboardFocus( nil )

return true

end

Runtime:addEventListener( “enterFrame”, checkKeyboard)

[/lua]

But, I think, its not the best solution.

Does your app resume after sending the email?

i.e. Is this happening:

  • call to native.showPopup()
  • app suspends and launches email app
  • email edit…send…
  • app resumes
  • keyboard still present over app

If so, add this code somewhere (main.lua is a good place) and run it ONCE only.  It will run forever after that and always try to ‘close keyboard’ on resume.

local function onSystemEvent ( event ) if( event.name == "applicationResume" ) then native.setKeyboardFocus( nil ) end end Runtime:addEventListener( "system", onSystemEvent )

Thank you, roaminggamer!

Your answer helped me to solve this problem.

https://docs.coronalabs.com/api/library/native/setKeyboardFocus.html

 native.setKeyboardFocus( nil )

Thanks for your reply!

Let me clarify - I do not understand at what time / in what place to call native.setKeyboardFocus( nil ).

native.showPopup(“mail”, options) doesn’t have listener for “mail”. Thats the problem.

I tried this code (and it works):

[lua]

local function checkKeyboard()   

native.setKeyboardFocus( nil )

return true

end

Runtime:addEventListener( “enterFrame”, checkKeyboard)

[/lua]

But, I think, its not the best solution.

Does your app resume after sending the email?

i.e. Is this happening:

  • call to native.showPopup()
  • app suspends and launches email app
  • email edit…send…
  • app resumes
  • keyboard still present over app

If so, add this code somewhere (main.lua is a good place) and run it ONCE only.  It will run forever after that and always try to ‘close keyboard’ on resume.

local function onSystemEvent ( event ) if( event.name == "applicationResume" ) then native.setKeyboardFocus( nil ) end end Runtime:addEventListener( "system", onSystemEvent )

Thank you, roaminggamer!

Your answer helped me to solve this problem.