1
0
Fork 0
baseview/examples/open_window.rs

32 lines
944 B
Rust
Raw Normal View History

2020-10-21 11:02:45 +11:00
use baseview::{Event, Window, WindowHandler, WindowScalePolicy};
struct OpenWindowExample;
impl WindowHandler for OpenWindowExample {
2020-09-08 12:36:54 +10:00
type Message = ();
fn on_frame(&mut self) {}
fn on_event(&mut self, _window: &mut Window, event: Event) {
match event {
2020-09-12 01:21:05 +10:00
Event::Mouse(e) => println!("Mouse event: {:?}", e),
Event::Keyboard(e) => println!("Keyboard event: {:?}", e),
2020-09-12 03:38:06 +10:00
Event::Window(e) => println!("Window event: {:?}", e),
}
}
fn on_message(&mut self, _window: &mut Window, _message: Self::Message) {}
2020-09-03 07:23:03 +10:00
}
2020-09-12 02:25:50 +10:00
fn main() {
let window_open_options = baseview::WindowOpenOptions {
title: "baseview".into(),
2020-10-21 11:02:45 +11:00
size: baseview::Size::new(512.0, 512.0),
scale: WindowScalePolicy::SystemScaleFactor,
2020-09-12 02:25:50 +10:00
parent: baseview::Parent::None,
};
let handle = Window::open(window_open_options, |_| OpenWindowExample);
2020-09-12 02:25:50 +10:00
handle.app_run_blocking();
}