Skip to content

add Draggable or DragTarget to stack in a container is not work? #318

@scriptiot-dev

Description

@scriptiot-dev
from inspect import stack
import flet
from flet import Stack, Container, Draggable, DragTarget, Page, Row, border, colors


def main(page: Page):
    page.title = "Drag and Drop example"
    _stack_ = Stack([])
    _container_ = Container(_stack_)
    c = Draggable(content=_container_)
    _container_.width = 800
    _container_.height = 480
    _container_.bgcolor = "#111234"

    _stack_2 = Stack([])
    _container_2 = Container(_stack_2)
    c2 = Draggable(content=_container_2)
    _container_2.bgcolor = "red"
    _container_2.height = 150
    _container_2.left = 300 
    _container_2.top = 300
    _container_2.width = 200

    _stack_.controls.append(_container_2)

    page.add(
        c
    )


flet.app(target=main)

image

i want to make _container_2 draggable

from inspect import stack
import flet
from flet import Stack, Container, Draggable, DragTarget, Page, Row, border, colors


def main(page: Page):
    page.title = "Drag and Drop example"
    _stack_ = Stack([])
    _container_ = Container(_stack_)
    c = Draggable(content=_container_)
    _container_.width = 800
    _container_.height = 480
    _container_.bgcolor = "#111234"

    _stack_2 = Stack([])
    _container_2 = Container(_stack_2)
    c2 = Draggable(content=_container_2)
    _container_2.bgcolor = "red"
    _container_2.height = 150
    _container_2.left = 300 
    _container_2.top = 300
    _container_2.width = 200

    _stack_.controls.append(c2)

    page.add(
        c
    )


flet.app(target=main)

1663124716534

from inspect import stack
import flet
from flet import Stack, Container, Draggable, DragTarget, Page, Row, border, colors


def main(page: Page):
    page.title = "Drag and Drop example"
    _stack_ = Stack([])
    _container_ = Container(_stack_)
    c = Draggable(content=_container_)
    _container_.width = 800
    _container_.height = 480
    _container_.bgcolor = "#111234"

    _stack_2 = Stack([])
    _container_2 = Container(_stack_2)
    c2 = DragTarget(content=_container_2)
    _container_2.bgcolor = "red"
    _container_2.height = 150
    _container_2.left = 300 
    _container_2.top = 300
    _container_2.width = 200

    _stack_.controls.append(c2)

    page.add(
        c
    )


flet.app(target=main)

make _container_2 DragTarget is same as Draggable

add Draggable or DragTarget to stack not work well

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