slint/internal/compiler/tests/syntax/elements/listview.slint
Olivier Goffart d468bbec05 ListView: Warn when we have other elements than just a for
This is not supported right now, the other elements will not be part of
the layout, and two `for` will be in the same listview, creating bad
situation with the scrollbar.

This is a warning since it would be a breaking change to make it an
error.

For example, we used a FocusScope in the StandardListView implementation so
I had to go trough one level of indirection

CC: #860
2022-11-30 11:17:22 +01:00

35 lines
No EOL
1.1 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
import { ListView } from "std-widgets.slint";
Foo := Rectangle {
ListView {
@children
// ^warning{A ListView can just have a single 'for' as children. Anything else is not supported}
}
}
Bar := Rectangle {
Foo { Text {} }
ListView {
Text {}
// ^warning{A ListView can just have a single 'for' as children. Anything else is not supported}
}
ListView {
Text { }
// ^warning{A ListView can just have a single 'for' as children. Anything else is not supported}
for x in 2: Rectangle {}
Text { }
// ^warning{A ListView can just have a single 'for' as children. Anything else is not supported}
for x in 2: Rectangle {}
// ^warning{A ListView can just have a single 'for' as children. Anything else is not supported}
}
ListView { for x in 2: Rectangle {} }
ListView {
for x in 2: Rectangle {}
for x in 2: Rectangle {}
// ^warning{A ListView can just have a single 'for' as children. Anything else is not supported}
}
}