Skip to content

fix(android): improve Window focus/blur events#14456

Draft
m1ga wants to merge 2 commits into
mainfrom
androidFocusBlur
Draft

fix(android): improve Window focus/blur events#14456
m1ga wants to merge 2 commits into
mainfrom
androidFocusBlur

Conversation

@m1ga

@m1ga m1ga commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Will fire blur/focus event when you drag down the statusbar on your phone.

Note: This will also fire when an alert is shown! That is currently not the case. So I'm not sure if we should use a different event for this as it may cause problems in existing apps.

var win = Ti.UI.createWindow({});
var btn = Ti.UI.createButton({
	title: "alert",
})

win.add(btn);
win.open();

win.addEventListener("focus", function(){
	console.log("win focus")
})
win.addEventListener("blur", function(){
	console.log("win blur")
})

btn.addEventListener("click", function(e) {
	alert(1);
})

I could change it to windowblur and windowfocus so you have a different event for these new blur/focus and it won't break any exisint blur/focus usage on a window

@hansemannn

Copy link
Copy Markdown
Collaborator

How does iOS behave here, especially for alerts? IIRC, it also fires blur/focus events prior/after showing alerts.

@m1ga

m1ga commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

need to check that on iOS.

Since an alert would fire a blur event on Android after that change it might be better to give it a different event name in case iOS doesn't do that. Otherwise it might fire blur in cases you don't want it because it is just showing an alert. But I'll test it on iOS next week and check how the events line up.

@m1ga

m1ga commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

running the example code with the current main (not using this PR) on iOS and Android:

  • iOS: blur/focus is fired already when opening/closing the alert
  • Android: no events when opening/closing the alert

so this PR will actually make Android behave the same way as iOS is doing right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants