-
Hi ! I'm defining a component in the UI side, in a file named chessboard.slint export component ChessBoard {
in property <[[string]]> pieces: [
["r", "n", "b", "q", "k", "b", "n", "r"],
["p", "p", "p", "p", "p", "p", "p", "p"],
["", "", "", "", "", "", "", ""],
["", "", "", "", "", "", "", ""],
["", "", "", "", "", "", "", ""],
["", "", "", "", "", "", "", ""],
["P", "P", "P", "P", "P", "P", "P", "P"],
["R", "N", "B", "Q", "K", "B", "N", "R"],
];
// other code defined in it
} in the application windows script, I'm using it as a sub component export component AppWindow inherits Window {
width: 900px;
height: 900px;
board:= ChessBoard {
size: 500px;
reversed: false;
whiteTurn: false;
}
} But I wonder how to set the pieces of the fn main() -> Result<(), slint::PlatformError> {
let ui = AppWindow::new()?;
let ui_handle = ui.as_weak();
ui.??? // How to change the pieces values of the board variable here ? I mean how to access the board variable from here ?
ui.run()
} |
Beta Was this translation helpful? Give feedback.
Answered by
ogoffart
Dec 19, 2023
Replies: 1 comment 1 reply
-
You can either forward the properties to the root component like so: export component AppWindow inherits Window {
in property pieces <=> board.pieces;
board:= ChessBoard {
// ...
}
} Or you use a global: https://slint.dev/releases/1.3.2/docs/slint/src/language/syntax/globals |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
loloof64
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can either forward the properties to the root component like so:
Or you use a global: https://slint.dev/releases/1.3.2/docs/slint/src/language/syntax/globals