Skip to content

Commit d8668ca

Browse files
committed
Select location text on ctrl+l; deselect on esc, click, or context menu
1 parent a9daddb commit d8668ca

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

src/app.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl Action {
153153
Action::DesktopViewOptions => Message::DesktopViewOptions,
154154
Action::EditHistory => Message::ToggleContextPage(ContextPage::EditHistory),
155155
Action::EditLocation => {
156-
Message::TabMessage(entity_opt, tab::Message::EditLocationToggle)
156+
Message::TabMessage(entity_opt, tab::Message::EditLocationEnable)
157157
}
158158
Action::ExtractHere => Message::ExtractHere(entity_opt),
159159
Action::Gallery => Message::TabMessage(entity_opt, tab::Message::GalleryToggle),
@@ -1475,6 +1475,11 @@ impl Application for App {
14751475
return Command::none();
14761476
}
14771477

1478+
if tab.edit_location.is_some() {
1479+
tab.edit_location = None;
1480+
return Command::none();
1481+
}
1482+
14781483
let had_focused_button = tab.select_focus_id().is_some();
14791484
if tab.select_none() {
14801485
if had_focused_button {
@@ -2936,6 +2941,12 @@ impl Application for App {
29362941

29372942
// Tracks which nav bar item to show a context menu for.
29382943
Message::NavBarContext(entity) => {
2944+
// Close location editing if enabled
2945+
let tab_entity = self.tab_model.active();
2946+
if let Some(tab) = self.tab_model.data_mut::<Tab>(tab_entity) {
2947+
tab.edit_location = None;
2948+
}
2949+
29392950
self.nav_bar_context_id = entity;
29402951
}
29412952

src/dialog.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,12 @@ impl Application for App {
10351035
return Command::none();
10361036
}
10371037

1038+
if self.tab.edit_location.is_some() {
1039+
// Close location editing if enabled
1040+
self.tab.edit_location = None;
1041+
return Command::none();
1042+
}
1043+
10381044
let had_focused_button = self.tab.select_focus_id().is_some();
10391045
if self.tab.select_none() {
10401046
if had_focused_button {

src/tab.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ pub enum Message {
972972
LocationMenuAction(LocationMenuAction),
973973
Drag(Option<Rectangle>),
974974
EditLocation(Option<Location>),
975-
EditLocationToggle,
975+
EditLocationEnable,
976976
OpenInNewTab(PathBuf),
977977
EmptyTrash,
978978
Gallery(bool),
@@ -2016,6 +2016,7 @@ impl Tab {
20162016
Message::Click(click_i_opt) => {
20172017
self.selected_clicked = false;
20182018
self.context_menu = None;
2019+
self.edit_location = None;
20192020
self.location_context_menu_index = None;
20202021
if click_i_opt.is_none() {
20212022
self.clicked = click_i_opt;
@@ -2150,6 +2151,7 @@ impl Tab {
21502151
commands.push(Command::Action(action));
21512152
}
21522153
Message::ContextMenu(point_opt) => {
2154+
self.edit_location = None;
21532155
if point_opt.is_none() || !mod_shift {
21542156
self.context_menu = point_opt;
21552157
//TODO: hack for clearing selecting when right clicking empty space
@@ -2234,12 +2236,11 @@ impl Tab {
22342236
}
22352237
self.edit_location = edit_location;
22362238
}
2237-
Message::EditLocationToggle => {
2238-
if self.edit_location.is_none() {
2239-
self.edit_location = Some(self.location.clone());
2240-
} else {
2241-
self.edit_location = None;
2242-
}
2239+
Message::EditLocationEnable => {
2240+
commands.push(Command::Iced(widget::text_input::focus(
2241+
self.edit_location_id.clone(),
2242+
)));
2243+
self.edit_location = Some(self.location.clone());
22432244
}
22442245
Message::OpenInNewTab(path) => {
22452246
commands.push(Command::OpenInNewTab(path));

0 commit comments

Comments
 (0)