Select location text on ctrl+l; deselect on esc, click, or context menu
This commit is contained in:
parent
a9daddb1b0
commit
d8668cae79
3 changed files with 26 additions and 8 deletions
13
src/app.rs
13
src/app.rs
|
|
@ -153,7 +153,7 @@ impl Action {
|
||||||
Action::DesktopViewOptions => Message::DesktopViewOptions,
|
Action::DesktopViewOptions => Message::DesktopViewOptions,
|
||||||
Action::EditHistory => Message::ToggleContextPage(ContextPage::EditHistory),
|
Action::EditHistory => Message::ToggleContextPage(ContextPage::EditHistory),
|
||||||
Action::EditLocation => {
|
Action::EditLocation => {
|
||||||
Message::TabMessage(entity_opt, tab::Message::EditLocationToggle)
|
Message::TabMessage(entity_opt, tab::Message::EditLocationEnable)
|
||||||
}
|
}
|
||||||
Action::ExtractHere => Message::ExtractHere(entity_opt),
|
Action::ExtractHere => Message::ExtractHere(entity_opt),
|
||||||
Action::Gallery => Message::TabMessage(entity_opt, tab::Message::GalleryToggle),
|
Action::Gallery => Message::TabMessage(entity_opt, tab::Message::GalleryToggle),
|
||||||
|
|
@ -1475,6 +1475,11 @@ impl Application for App {
|
||||||
return Command::none();
|
return Command::none();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if tab.edit_location.is_some() {
|
||||||
|
tab.edit_location = None;
|
||||||
|
return Command::none();
|
||||||
|
}
|
||||||
|
|
||||||
let had_focused_button = tab.select_focus_id().is_some();
|
let had_focused_button = tab.select_focus_id().is_some();
|
||||||
if tab.select_none() {
|
if tab.select_none() {
|
||||||
if had_focused_button {
|
if had_focused_button {
|
||||||
|
|
@ -2936,6 +2941,12 @@ impl Application for App {
|
||||||
|
|
||||||
// Tracks which nav bar item to show a context menu for.
|
// Tracks which nav bar item to show a context menu for.
|
||||||
Message::NavBarContext(entity) => {
|
Message::NavBarContext(entity) => {
|
||||||
|
// Close location editing if enabled
|
||||||
|
let tab_entity = self.tab_model.active();
|
||||||
|
if let Some(tab) = self.tab_model.data_mut::<Tab>(tab_entity) {
|
||||||
|
tab.edit_location = None;
|
||||||
|
}
|
||||||
|
|
||||||
self.nav_bar_context_id = entity;
|
self.nav_bar_context_id = entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1035,6 +1035,12 @@ impl Application for App {
|
||||||
return Command::none();
|
return Command::none();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.tab.edit_location.is_some() {
|
||||||
|
// Close location editing if enabled
|
||||||
|
self.tab.edit_location = None;
|
||||||
|
return Command::none();
|
||||||
|
}
|
||||||
|
|
||||||
let had_focused_button = self.tab.select_focus_id().is_some();
|
let had_focused_button = self.tab.select_focus_id().is_some();
|
||||||
if self.tab.select_none() {
|
if self.tab.select_none() {
|
||||||
if had_focused_button {
|
if had_focused_button {
|
||||||
|
|
|
||||||
15
src/tab.rs
15
src/tab.rs
|
|
@ -972,7 +972,7 @@ pub enum Message {
|
||||||
LocationMenuAction(LocationMenuAction),
|
LocationMenuAction(LocationMenuAction),
|
||||||
Drag(Option<Rectangle>),
|
Drag(Option<Rectangle>),
|
||||||
EditLocation(Option<Location>),
|
EditLocation(Option<Location>),
|
||||||
EditLocationToggle,
|
EditLocationEnable,
|
||||||
OpenInNewTab(PathBuf),
|
OpenInNewTab(PathBuf),
|
||||||
EmptyTrash,
|
EmptyTrash,
|
||||||
Gallery(bool),
|
Gallery(bool),
|
||||||
|
|
@ -2016,6 +2016,7 @@ impl Tab {
|
||||||
Message::Click(click_i_opt) => {
|
Message::Click(click_i_opt) => {
|
||||||
self.selected_clicked = false;
|
self.selected_clicked = false;
|
||||||
self.context_menu = None;
|
self.context_menu = None;
|
||||||
|
self.edit_location = None;
|
||||||
self.location_context_menu_index = None;
|
self.location_context_menu_index = None;
|
||||||
if click_i_opt.is_none() {
|
if click_i_opt.is_none() {
|
||||||
self.clicked = click_i_opt;
|
self.clicked = click_i_opt;
|
||||||
|
|
@ -2150,6 +2151,7 @@ impl Tab {
|
||||||
commands.push(Command::Action(action));
|
commands.push(Command::Action(action));
|
||||||
}
|
}
|
||||||
Message::ContextMenu(point_opt) => {
|
Message::ContextMenu(point_opt) => {
|
||||||
|
self.edit_location = None;
|
||||||
if point_opt.is_none() || !mod_shift {
|
if point_opt.is_none() || !mod_shift {
|
||||||
self.context_menu = point_opt;
|
self.context_menu = point_opt;
|
||||||
//TODO: hack for clearing selecting when right clicking empty space
|
//TODO: hack for clearing selecting when right clicking empty space
|
||||||
|
|
@ -2234,12 +2236,11 @@ impl Tab {
|
||||||
}
|
}
|
||||||
self.edit_location = edit_location;
|
self.edit_location = edit_location;
|
||||||
}
|
}
|
||||||
Message::EditLocationToggle => {
|
Message::EditLocationEnable => {
|
||||||
if self.edit_location.is_none() {
|
commands.push(Command::Iced(widget::text_input::focus(
|
||||||
self.edit_location = Some(self.location.clone());
|
self.edit_location_id.clone(),
|
||||||
} else {
|
)));
|
||||||
self.edit_location = None;
|
self.edit_location = Some(self.location.clone());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Message::OpenInNewTab(path) => {
|
Message::OpenInNewTab(path) => {
|
||||||
commands.push(Command::OpenInNewTab(path));
|
commands.push(Command::OpenInNewTab(path));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue