Add support for invoking an init callback on component and element construction

This enables imperative code to be run. To be used sparingly :-)
This commit is contained in:
Simon Hausmann 2022-11-15 14:24:38 +01:00 committed by Simon Hausmann
parent 9baf6f2bde
commit 907b58161c
20 changed files with 366 additions and 46 deletions

View file

@ -0,0 +1,14 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
global Singleton := {
callback init;
// ^error{A global component cannot have an 'init' callback}
init => { debug("nope"); }
// ^error{A global component cannot have an 'init' callback}
}
Test := Rectangle {
callback init;
// ^error{Cannot override callback 'init'}
}