Skip to content

Commit

Permalink
Merge branch 'main' into feature/unread_mentions_highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinaboos authored Jan 26, 2025
2 parents 9e509a3 + 0f76f01 commit fd243eb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
18 changes: 12 additions & 6 deletions src/home/loading_pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,20 +175,25 @@ impl Widget for LoadingPane {
if !self.visible { return; }
self.view.handle_event(cx, event, scope);

let area = self.view.area();

// Close the pane if:
// 1. The cancel button is clicked,
// 2. The back navigational gesture/action occurs (e.g., Back on Android),
// 3. The escape key is pressed
// 3. The escape key is pressed if this pane has key focus,
// 4. The back mouse button is clicked within this view,
// 5. The user clicks/touches outside the main_content view area.
let close_pane = match event {
Event::Actions(actions) => self.button(id!(cancel_button)).clicked(actions), // 1
Event::BackPressed => true, // 2
Event::KeyUp(key) => key.key_code == KeyCode::Escape, // 3
_ => false,
} || match event.hits_with_capture_overload(cx, self.view.area(), true) {
// Note: ideally we should handle `Hit::KeyUp` here, but that doesn't work as expected.
Hit::FingerUp(fue) => {
} || match event.hits_with_capture_overload(cx, area, true) {
Hit::KeyUp(key) => key.key_code == KeyCode::Escape, // 3
Hit::FingerDown(_fde) => {
cx.set_key_focus(area);
false
}
Hit::FingerUp(fue) if fue.is_over => {
fue.mouse_button().is_some_and(|b| b.is_back()) // 4
|| !self.view(id!(main_content)).area().rect(cx).contains(fue.abs) // 5
}
Expand All @@ -208,7 +213,7 @@ impl Widget for LoadingPane {
);
}
self.set_state(cx, LoadingPaneState::None);

cx.revert_key_focus();
self.visible = false;
}
}
Expand All @@ -223,6 +228,7 @@ impl LoadingPane {

pub fn show(&mut self, cx: &mut Cx) {
self.visible = true;
cx.set_key_focus(self.view.area());
self.redraw(cx);
}

Expand Down
17 changes: 12 additions & 5 deletions src/profile/user_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ impl Widget for UserProfileSlidingPane {
match (self.is_animating_out, animator_action.is_animating()) {
(true, false) => {
self.visible = false;
cx.revert_key_focus();
self.view(id!(bg_view)).set_visible(cx, false);
self.redraw(cx);
return;
Expand All @@ -435,20 +436,25 @@ impl Widget for UserProfileSlidingPane {
}
}

let area = self.view.area();

// Close the pane if:
// 1. The close button is clicked,
// 2. The back navigational gesture/action occurs (e.g., Back on Android),
// 3. The escape key is pressed,
// 3. The escape key is pressed if this pane has key focus,
// 4. The back mouse button is clicked within this view,
// 5. The user clicks/touches outside the main_content view area.
let close_pane = match event {
Event::Actions(actions) => self.button(id!(close_button)).clicked(actions), // 1
Event::BackPressed => true, // 2
Event::KeyUp(key) => key.key_code == KeyCode::Escape, // 3
_ => false,
} || match event.hits_with_capture_overload(cx, self.view.area(), true) {
// Note: ideally we should handle `Hit::KeyUp` here, but that doesn't work as expected.
Hit::FingerUp(fue) => {
} || match event.hits_with_capture_overload(cx, area, true) {
Hit::KeyUp(key) => key.key_code == KeyCode::Escape, // 3
Hit::FingerDown(_fde) => {
cx.set_key_focus(area);
false
}
Hit::FingerUp(fue) if fue.is_over => {
fue.mouse_button().is_some_and(|b| b.is_back()) // 4
|| !self.view(id!(main_content)).area().rect(cx).contains(fue.abs) // 5
}
Expand Down Expand Up @@ -647,6 +653,7 @@ impl UserProfileSlidingPane {

pub fn show(&mut self, cx: &mut Cx) {
self.visible = true;
cx.set_key_focus(self.view.area());
self.animator_play(cx, id!(panel.show));
self.view(id!(bg_view)).set_visible(cx, true);
self.redraw(cx);
Expand Down

0 comments on commit fd243eb

Please sign in to comment.