Skip to content
This repository was archived by the owner on Dec 24, 2025. It is now read-only.
This repository was archived by the owner on Dec 24, 2025. It is now read-only.

WebView Focus #7

@egru5

Description

@egru5

When focusing a WebView, it is hard to switch focus again.

When creating a flet web app, and using flet webView and a keyboard event, the webView captures all focus of the keyboard events.

Here a short example:

import flet as ft
import flet_webview as fwv


def main(page: ft.Page):
    def on_keyboard(e: ft.KeyboardEvent):
        page.add(
            ft.Text(
                f"Key: {e.key}, Shift: {e.shift}, Control: {e.ctrl}, Alt: {e.alt}, Meta: {e.meta}"
            )
        )

    page.on_keyboard_event = on_keyboard
    page.add(
        ft.Row(
            controls=[
                ft.Text(
                    "Press any key with a combination of CTRL, ALT, SHIFT and META keys..."
                ),
                fwv.WebView(
                    url="https://flet.dev",
                    on_page_started=lambda _: print("Page started"),
                    on_page_ended=lambda _: print("Page ended"),
                    on_web_resource_error=lambda e: print("Page error:", e.data),
                    expand=True,
                ),
            ],
            expand=True,
        )
    )

ft.app(main)

as soon as i press into the webview, the keyboard events on the flet page do not get fired.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions