Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't bring global to Rust scope #5451

Closed
RstyDev opened this issue Jun 21, 2024 · 2 comments
Closed

Can't bring global to Rust scope #5451

RstyDev opened this issue Jun 21, 2024 · 2 comments

Comments

@RstyDev
Copy link

RstyDev commented Jun 21, 2024

Hi, I'm using Slint with Rust in both RustRover and VSCode, in W10 and I have the same problem.
There's no way I can get my global export in scope from Rust.
I tried declaring it in a single file, in the main Slint file and in the macro slint::slint!, but had no results.
I also tried deleting the export and re-importing in all possible orders but still can't make it work.
I can call my global from other slint files, the problem is to call it from Rust.
` slint::include_modules!();
slint::slint!{
export global Logic := {
callback pagar(int,int);
}
}
mod db;
mod mods;

fn main()->Result<(),slint::PlatformError> {
let ui = AppWindow::new()?;
let ui_handle = ui.as_weak();
ui.global::(); //<-- here's the problem
ui.on_request_increase_value(move || {
let ui= ui_handle.unwrap();
ui.set_counter(ui.get_counter() + 1);
});
ui.run()
}`

@Vadoola
Copy link

Vadoola commented Jun 21, 2024

I'm on mobile so its hard to test, but if I recall you need Turbofish syntax here: ui.global::<Logic>().Pager()

@RstyDev
Copy link
Author

RstyDev commented Jun 21, 2024

I had tried, but it was the same, so I kept trying and it turned out to be that I had changed the directory of the project just copying and pasting the files. Then the compiler stopped adding changes to the target folder. Thanks a lot for your help!

@RstyDev RstyDev closed this as completed Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants