Skip to content

Commit

Permalink
Adds code for right-click menu for TextEdit
Browse files Browse the repository at this point in the history
Does not work because TextEdit lacks Sense(click)
Thought for issue #32
  • Loading branch information
margual56 committed Aug 21, 2023
1 parent b789756 commit 8937cc4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
**/dist/*
.vscode/
**/*.wb
.cargo/config.toml
9 changes: 0 additions & 9 deletions assets/save_file.js

This file was deleted.

1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<link data-trunk rel="copy-file" href="assets/sw.js" />
<link data-trunk rel="copy-file" href="assets/manifest.json" />
<link data-trunk rel="copy-file" href="assets/icon.png" />
<link data-trunk rel="copy-file" href="assets/save_file.js" />


<link rel="manifest" href="manifest.json">
Expand Down
21 changes: 17 additions & 4 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,16 +910,29 @@ impl MyApp {
.show(ui, |my_ui: &mut Ui| {
let editor = TextEdit::multiline(&mut self.code)
.code_editor()
.desired_width(0.0);
.desired_width(0.0).show(my_ui);

let res = my_ui.add(editor);
let res = editor.response;

if self.autosave && res.lost_focus() {
debug!("Saving file");
self.saved_feedback = self.auto_save_file();
}

*editor_focused = res.has_focus().clone();

*editor_focused = (&res).has_focus().clone();

// FIXME: Does not work because TextEdit is lacking the Sense(click)
// res.context_menu(|ui| {
// if ui.button("Copy").clicked() {
// if let Some(cursor_range) = editor.cursor_range {
// let start = cursor_range.primary.ccursor.index;
// let end = cursor_range.secondary.ccursor.index;

// let text = &self.code[start..end];
// ui.output_mut(|o| o.copied_text = String::from(text));
// }
// }
// });
});

if ui.button(t!("btn.libraries", lang)).clicked() {
Expand Down

0 comments on commit 8937cc4

Please sign in to comment.