-
Notifications
You must be signed in to change notification settings - Fork 640
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Duplicate Check
- I have searched the opened issues and there are no duplicates
Describe the bug
In macOS, pressing Command + Q will immediately terminate the program and cannot trigger a custom keyboard event.
Code sample
Code
import flet as ft
def main(page: ft.Page):
async def handle_exit(_: ft.Event[ft.TextButton]):
await page.window.close()
def show_exit_confirm():
page.show_dialog(
ft.AlertDialog(
title=ft.Text("info"),
content=ft.Text("Do you want to quit?"),
actions=[
ft.TextButton("Cancel", on_click=lambda e: page.pop_dialog()),
ft.TextButton("Quit", on_click=handle_exit),
],
)
)
def on_keyboard(e: ft.KeyboardEvent):
if e.meta and e.key == "Q":
show_exit_confirm()
page.on_keyboard_event = on_keyboard
page.add(
ft.Text("hello workd")
)
ft.run(main)To reproduce
1.uv run flet run main.py run code
2.pressing Command + Q
3.program immediately exits
Expected behavior
I created a dialog box for exit confirmation. I hope that when the exit shortcut key is triggered, an exit confirmation dialog will be displayed first instead of directly terminating the program.
Screenshots / Videos
Captures
[Upload media here]
Operating System
macOS
Operating system details
macOS 15
Flet version
0.82.2
Regression
I'm not sure / I don't know
Suggestions
No response
Logs
Logs
[Paste your logs here]Additional details
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working