Even more work

This commit is contained in:
TheTechRobo 2022-08-12 12:32:25 -04:00
parent d024710fc3
commit 3ce8558371
1 changed files with 9 additions and 6 deletions

View File

@ -125,14 +125,16 @@ fn create_app(title: String, width: i32, height: i32, mut window: Window) -> App
let buffer = EntryBuffer::new(Some("hi"));
let input = Entry::with_buffer(&buffer);
input.connect_changed(|e| {
let uuid = e.widget_name();
LUA.with(|st| {
let lua = st.borrow_mut();
lua.load(r#"
for key, value in ipairs(input_changed) do
print(key, value)
end"#).exec().expect("Failed to run Lua");
let script = format!(r#"
for key, func in ipairs(input_changed) do
func("{}")
end"#, uuid);
lua.load(&script).exec().expect("Failed to run Lua");
});
set_title(get_window_from_widget(e.toplevel().unwrap()).unwrap(), "hi");
set_title(get_window_from_widget(e.toplevel().unwrap()).unwrap(), &uuid);
});
println!("{}", add_widget(bobox, input));
@ -156,6 +158,7 @@ fn set_title(window: gtk::gdk::Window, text: &str) {
fn add_widget<T: IsA<gtk::Widget>>(cont: gtk::Box, widget: T) -> String {
let uuid: String = uuidv7::create();
widget.set_widget_name(&uuid);
cont.add(&widget);
uuid
}
@ -193,7 +196,7 @@ fn setup_lua() -> LuaResult<()> {
Ok(())
})?;
lua.globals().set("item", f)?;
lua.load(r#"input_changed = {}"#).exec()?;
lua.load(r#"input_changed = {item}"#).exec()?;
Ok(())
})?;
Ok(())