Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

bug: The on_interaction_update event of the InteractiveViewer component has an error in the data returned

Aperta
#6,469 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
flutter, python
Ambito
frontend

Direzione di ricerca

Inizia con la riproduzione Python fornita e con il punto di ingresso ft.InteractiveViewer on_interaction_update, quindi segui come vengono restituiti i dati di interaction_update_interval. Verifica il comportamento con tre eventi della rotellina del mouse entro 200 millisecondi; l'attività è completata quando il callback segnala il loro risultato cumulativo senza richiedere un intervallo di 0.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Duplicate Check
Describe the bug

In the ft.InteractiveViewer() component, if interaction_update_interval is set to 200 milliseconds, the returned data should include all events that occurred within that interval. For example, if I trigger three scroll wheel events within 200 milliseconds, it should return the cumulative result of those three scroll events. However, Flet actually returns the data for only one event. To get correct data, you need to set interaction_update_interval to 0, but this causes significant performance overhead.

Code sample
Code

import flet as ft
from typing import  cast


@ft.control
class BaseCanvas(ft.GestureDetector):
    max_scale: float = 3
    scale_step: float = 0.25
    min_scale: float = 0.25

    def init(self):
        self.cumulative_offset_x = self.cumulative_offset_y = 0
        self.current_scale = 1

        self.window_container_size = ()
        self.canvas_size=()
        
        
        self.scaled_canvas_size = ()
        self.scale_offset_x = 0
        self.scale_offset_y = 0

        self.canvas_container = ft.Container(
            bgcolor=ft.Colors.BLUE_100,
            content=ft.Stack(
                controls=[
                    self.module_container((50, 50)),
                    self.module_container((50, 600)),
                    self.module_container((1000, 50)),
                    self.module_container((1000, 600)),
                ],
            ),
        )

        self.content = ft.InteractiveViewer(
            expand=True,
            clip_behavior= ft.ClipBehavior.HARD_EDGE,
            content=self.canvas_container,
            on_size_change = lambda e: self.get_window_container_size(e),
            constrained = False,
            on_interaction_update=lambda e:  print(e),

        )


        self.on_hover = self.mouse_hover_event

    def module_container(self, pos):
        module = ft.Container(
            bgcolor=ft.Colors.GREEN,
            width=70,
            content=ft.Column(
                [
                    ft.Container(width=70, content=ft.Text(f"module {j}"))
                    for j in range(10)
                ]
            ),
        )

        return ft.GestureDetector(
            mouse_cursor=ft.MouseCursor.MOVE,
            drag_interval=5,
            left=pos[0],
            top=pos[1],
            content=module,
        )

    def get_window_container_size(self, e):

        self.window_container_size = (e.width, e.height)
        if not self.canvas_size or self.canvas_size<self.window_container_size:
            self.canvas_size=self.window_container_size


            self.canvas_container.width,self.canvas_container.height=self.window_container_size
            self.canvas_container=cast(ft.Container,self.canvas_container)
            self.canvas_container.update()
        print(self.window_container_size)

    def mouse_hover_event(self, e: ft.HoverEvent[ft.GestureDetector]) -> None:
        """Handle mouse hover, compute canvas coordinates"""
        if e.local_delta is None:
            return







if __name__ == "__main__":

    def main(page: ft.Page):
        canvas = BaseCanvas()
        page.add(
            ft.Container(expand=True,bgcolor=ft.Colors.AMBER, content=canvas),
        )

    ft.run(main)


To reproduce
  1. Run the code
  2. Scale to the maximum size
  3. Observe the scale data returned by the on_interaction_update event.
Expected behavior

No response

Screenshots / Videos
Captures

[Upload media here]

Operating System

Windows

Operating system details

11

Flet version

0.85

Regression

No, it isn't

Suggestions

No response

Logs
Logs
[Paste your logs here]
Additional details

No response

Lingua principale
Python
Stelle
17.4k
Fork
737
Merge medio
1g 8h
PR unite (30g)
46

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di flet-dev/flet

Tutte le issue di flet-dev/flet

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.