Files
LLeMbas-TTY/window/examples/basic.rs
T
2019-09-15 19:09:08 -07:00

36 lines
669 B
Rust

use ::window::*;
use failure::Fallible;
struct MyWindow {
allow_close: bool,
}
impl WindowCallbacks for MyWindow {
fn can_close(&mut self) -> bool {
eprintln!("can I close?");
if self.allow_close {
Connection::get().unwrap().terminate_message_loop();
true
} else {
self.allow_close = true;
false
}
}
}
fn main() -> Fallible<()> {
let conn = Connection::init()?;
let win = Window::new_window(
"myclass",
"the title",
800,
600,
Box::new(MyWindow { allow_close: false }),
)?;
win.show();
conn.run_message_loop()
}