slint/internal/compiler/tests/syntax/new_syntax/input_output.slint
Simon Hausmann 24dcef5fed
First stage of cleaning up the export handling of the slint root component (#2095)
We implicitly export the last component of a .slint file to the generator.
Issue a warning when that happens and suggest to export it explicitly.
2023-01-23 15:19:49 +01:00

102 lines
2.4 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
component Compo inherits Rectangle {
property <int> priv1: 42;
private property <int> priv2: priv1;
out property <int> output1: priv2;
in property <int> input1: output1;
in-out property <int> inout1: input1;
TouchArea {
clicked => {
priv1 = 32;
priv2 = 78;
output1 = input1;
input1 = 75;
inout1 = 75;
}
pressed: true;
// ^error{Cannot assign to output property 'pressed'}
}
states [
xxx when false : {
priv1: 42;
priv2: 55;
output1: 55;
input1: 12;
// ^error{'input1' cannot be set in a state because it is input}
inout1: 78;
}
]
animate input1 {}
// ^error{Cannot animate input property 'input1'}
}
OldCompo := Rectangle {
property <int> inout2: 42;
private property <int> priv2: inout2;
out property <int> output1: priv2;
in property <int> input1: output1;
in-out property <int> inout1: input1;
TouchArea {
clicked => {
pub1 = 32;
priv2 = 78;
output1 = input1;
input1 = 75;
inout1 = 75;
}
}
}
export component Foo inherits Rectangle {
c1 := OldCompo {
inout2: 42;
priv2: 55;
// ^error{Cannot assign to private property 'priv2'}
output1: 855;
// ^error{Cannot assign to output property 'output1'}
input1: 12;
inout1: 78;
animate output1 {}
// ^error{Cannot animate output property 'output1'}
animate priv2 {}
// ^error{Cannot animate private property 'priv2'}
}
c2 := Compo {
priv1: 42;
// ^error{Cannot assign to private property 'priv1'}
priv2: 55;
// ^error{Cannot assign to private property 'priv2'}
output1: 585;
// ^error{Cannot assign to output property 'output1'}
input1: 12;
inout1: 78;
}
states [
foo when true: {
c2.priv1: 45;
// ^error{'c2.priv1' cannot be set in a state because it is private}
c1.priv2: 89;
// ^error{'c1.priv2' cannot be set in a state because it is private}
c2.output1: 55;
// ^error{'c2.output1' cannot be set in a state because it is output}
}
]
}