所以我有一个用 Rust 编写的简单的 egui 应用程序,当我在窗口上单击鼠标左键并拖动时,我想在屏幕上拖动我的窗口。
这是我的窗口:
fn main() {
let nativeoption = eframe::NativeOptions {
always_on_top: false,
maximized: false,
decorated: true,
fullscreen: false,
drag_and_drop_support: true,
initial_window_size: Option::from(egui::Vec2::new(300f32, 300f32)),
min_window_size: None,
max_window_size: None,
resizable: true,
..Default::default()
};
eframe::run_native(
"my egui app",
nativeoption,
Box::new(|cc| Box::new(MyEguiApp::new(cc))),
)
.expect("TODO: panic message");
}
#[derive(Default)]
struct MyEguiApp {
name: String,
}
impl MyEguiApp {
fn new(cc: &eframe::CreationContext<'_>) -> Self {
MyEguiApp {
name: String::new(),
};
Self::default()
}
}
impl eframe::App for MyEguiApp {
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("hello welcome to egui");
ui.separator();
ui.horizontal(|ui| {
ui.label("Enter your name");
let res = ui.text_edit_singleline(&mut self.name);
});
ui.label(format!("my name is {}", &self.name));
});
}
}
我希望能够使用鼠标/光标将其拖动到任何地方。