Added copy password button
This commit is contained in:
parent
2b0cb6afe6
commit
422f4a804f
|
|
@ -7,7 +7,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
native-windows-derive = { version = "1.0.5"}
|
native-windows-derive = { version = "1.0.5"}
|
||||||
native-windows-gui = { version = "1.0.12"}
|
native-windows-gui = { version = "1.0.12", features = ["clipboard"]}
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
10
src/main.rs
10
src/main.rs
|
|
@ -51,6 +51,11 @@ pub struct RustPasswordGenerator {
|
||||||
#[nwg_layout_item(layout: grid, col: 1, row: 2, col_span: 5)]
|
#[nwg_layout_item(layout: grid, col: 1, row: 2, col_span: 5)]
|
||||||
result_text: nwg::TextInput,
|
result_text: nwg::TextInput,
|
||||||
|
|
||||||
|
#[nwg_control(text: "Copy")]
|
||||||
|
#[nwg_layout_item(layout: grid, col: 7, row: 2)]
|
||||||
|
#[nwg_events( OnButtonClick: [ RustPasswordGenerator::copy_password])]
|
||||||
|
copy_btn: nwg::Button,
|
||||||
|
|
||||||
#[nwg_control(text: "Generate")]
|
#[nwg_control(text: "Generate")]
|
||||||
#[nwg_layout_item(layout: grid, col: 4, row: 3)]
|
#[nwg_layout_item(layout: grid, col: 4, row: 3)]
|
||||||
#[nwg_events( OnButtonClick: [ RustPasswordGenerator::generate_password ] )]
|
#[nwg_events( OnButtonClick: [ RustPasswordGenerator::generate_password ] )]
|
||||||
|
|
@ -87,6 +92,11 @@ impl RustPasswordGenerator {
|
||||||
self.result_text.set_text(&password);
|
self.result_text.set_text(&password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn copy_password(&self) {
|
||||||
|
let text = self.result_text.text();
|
||||||
|
nwg::Clipboard::set_data_text(&self.window, &text);
|
||||||
|
}
|
||||||
|
|
||||||
fn show_error(&self, message: &str) {
|
fn show_error(&self, message: &str) {
|
||||||
nwg::modal_error_message(&self.window, "error!", message);
|
nwg::modal_error_message(&self.window, "error!", message);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user