gpui: Add is_action_available_in function (#45029)
This compliments the `window.is_action_available` function that already exists. Release Notes: - N/A
This commit is contained in:
1 parent
7a4fb24191
commit
d752b37d5d
1 file changed
+9
-1
@@ -1961,7 +1961,7 @@ impl Window {
|
||||
}
|
||||
|
||||
/// Determine whether the given action is available along the dispatch path to the currently focused element.
|
||||
pub fn is_action_available(&self, action: &dyn Action, cx: &mut App) -> bool {
|
||||
pub fn is_action_available(&self, action: &dyn Action, cx: &App) -> bool {
|
||||
let node_id =
|
||||
self.focus_node_id_in_rendered_frame(self.focused(cx).map(|handle| handle.id));
|
||||
self.rendered_frame
|
||||
@@ -1969,6 +1969,14 @@ impl Window {
|
||||
.is_action_available(action, node_id)
|
||||
}
|
||||
|
||||
/// Determine whether the given action is available along the dispatch path to the given focus_handle.
|
||||
pub fn is_action_available_in(&self, action: &dyn Action, focus_handle: &FocusHandle) -> bool {
|
||||
let node_id = self.focus_node_id_in_rendered_frame(Some(focus_handle.id));
|
||||
self.rendered_frame
|
||||
.dispatch_tree
|
||||
.is_action_available(action, node_id)
|
||||
}
|
||||
|
||||
/// The position of the mouse relative to the window.
|
||||
pub fn mouse_position(&self) -> Point<Pixels> {
|
||||
self.mouse_position
|
||||
|
||||
Reference in new issue
Block a user