Bläddra i källkod

Demonstrate dialog event registration (#4153)

Rodja Trappe 4 månader sedan
förälder
incheckning
4aee1d1910
1 ändrade filer med 14 tillägg och 0 borttagningar
  1. 14 0
      website/documentation/content/dialog_documentation.py

+ 14 - 0
website/documentation/content/dialog_documentation.py

@@ -48,4 +48,18 @@ def replace_content():
     ui.button('Replace', on_click=replace)
 
 
+@doc.demo('Events', '''
+    Dialogs emit events when they are opened or closed.
+    See the [Quasar documentation](https://quasar.dev/vue-components/dialog) for more information.
+''')
+def events():
+    with ui.dialog().props('backdrop-filter="blur(8px) brightness(40%)"') as dialog:
+        ui.label('Press ESC to close').classes('text-3xl text-white')
+
+    dialog.on('show', lambda: ui.notify('Dialog opened'))
+    dialog.on('hide', lambda: ui.notify('Dialog closed'))
+    dialog.on('escape-key', lambda: ui.notify('ESC pressed'))
+    ui.button('Open', on_click=dialog.open)
+
+
 doc.reference(ui.dialog)