`PasswordInput` brings up Apple password manager on MacOS but `on_change` doesn't fire
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 827
- Avg merge
- 15h 39m
- Merged PRs (30d)
- 40
Description
### Describe the bug
On MacOS, when using a `PasswordInput` as the second or later field, when you move focus to the password field it brings up a menu to fill the field from the password manager (this _doesn't_ happen if the field is the default editable field):

If you then go through the password manager and select a password, the obscured password is entered into the field, but the change handler doesn't fire.

Everything works as expected if you use the right-click -> "AutoFill" -> "Passwords" menu.
This is on macOS Sonoma 14.5, Python 3.12.4 and Toga 0.4.5 installed via pip.
### Steps to reproduce
1. Run the following code:
``` python
import toga
def build(app):
def handle_change(widget, /, **kwargs):
print(widget.value)
username_label = toga.Label("Username:")
username = toga.TextInput(on_change=handle_change)
password_label = toga.Label("Password:")
password = toga.PasswordInput(on_change=handle_change)
box = toga.Box(
children=[toga.Box(
children=[username_label, username],
),
toga.Box(
children=[password_label, password],
)],
)
box.style.direction = "column"
return box
def main():
return toga.App("Password Example", "com.example.password", startup=build)
if __name__ == "__main__":
main().main_loop()
```
2. Click on the password field
3. Select a password via the Apple password manager
4. Observe that nothing is printed by the change handler.
### Expected behavior
~1. The password pop-up possibly shouldn't appear (but it can be dismissed easily by pressing escape, and if this is a MacOS behaviour there is nothing to be done).~ Edit: this behaviour seems to be controlled by the control panel settings for password autofill (see discussion), so not something Toga can control.
2. When the password is auto-filled, the `on_change` handler should fire.
### Screenshots
_No response_
### Environment
- Operating System: macOS Sonoma 14.5
- Python version: 3.12.4
- Software versions:
- Toga: 0.4.5
Machine is a Mac Studio (Apple Silicon M1), Python was installed via MacPorts, toga via `pip` in a dedicated venv:
```
Package Version Editable project location
------------ ------- -------------------------------
fonttools 4.53.1
pip 24.1
rubicon-objc 0.4.9
toga 0.4.5
toga-cocoa 0.4.5
toga-core 0.4.5
travertino 0.3.0
```
### Logs
```
```
### Additional context
When I have some spare cycles I will run against the main branch of the various projects to make sure this hasn't been fixed since the last release, but I couldn't see any issues which matched this.
Contributor guide
Research direction
Reproduce the issue on macOS using the Python example in the report, then trace PasswordInput's native macOS event handling and how autofill updates the field. Confirm that selecting a password through Apple’s password manager invokes on_change, while preserving the existing right-click AutoFill behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- macos, python
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100