slint/internal/compiler/tests/syntax/elements/contextmenu.slint
Olivier Goffart 39191e5acd
Menu API changes
`ContextMenu` -> `ContextMenuArea`

`ContextMenu` must have a `Menu` child.
`MenuItem` can no longer be put dirrectly in `MenuBar` and can no longer
have children
`Menu` is used now for sub menus
2025-02-21 16:03:47 +01:00

48 lines
1.3 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
export component A {
ContextMenuArea {
show => {
// ^error{'show' is not a callback in ContextMenuArea}
debug("hello");
}
Menu {
}
property <int> entries: 45;
// ^error{Cannot re-define internal property 'entries'}
property <int> sub-menu: 45;
// ^error{Cannot re-define internal property 'sub-menu'}
property <string> activated: "me";
// ^error{Cannot re-define internal property 'activated'}
property <string> xyz: "me";
}
ContextMenuArea { Rectangle {} }
// ^error{ContextMenuArea should have a Menu}
ContextMenuArea {
Menu {
MenuItem { title: "ok"; }
}
Menu {
// ^error{Only one Menu is allowed in a ContextMenu}
MenuItem { title: "hello"; }
}
}
ContextMenuArea {
if false : Menu {}
// ^error{ContextMenuArea's root Menu cannot be in a conditional or repeated element}
}
ContextMenuArea {
for _ in [1,2,3] : Menu {}
// ^error{ContextMenuArea's root Menu cannot be in a conditional or repeated element}
}
}