Font panel: a single click on a card opens its details

This commit is contained in:
aiongg
2026-11-26 01:28:50 +00:00
parent 0b8bbaf4c8
commit 8e921ce1a3
2 changed files with 19 additions and 5 deletions
@@ -1,7 +1,7 @@
//! The family card and the collection of cards the panel lists.
use craft_ui::buttons::{SplitButton, SplitOutput};
use craft_ui::contract::{Entry, Props as _, Styled as _, clicked};
use craft_ui::contract::{ActivateOn, Entry, Props as _, Styled as _, clicked};
use super::{
Access, Badge, Button, Collection, CollectionProps, CollectionResponse, Common, Component, ComponentStyle, ContainerProps, Cow, Cx, DisplayOrder,
@@ -440,7 +440,7 @@ pub struct FamilyCardsStyle {
metrics: Metrics,
}
/// The family cards of one list: one Tab stop, Up and Down move the lead, Enter or a double click activates a card.
/// The family cards of one list: one Tab stop, Up and Down move the lead, Enter or a click activates a card.
#[derive(craft_ui::contract::Component)]
#[component(collection)]
pub struct FamilyCards {
@@ -457,7 +457,7 @@ impl FamilyCards {
FamilyCards {
common: Common::new(),
props: ContainerProps::new().sizing(Sizing::Fill),
items: CollectionProps::new().select(SelectMode::Single),
items: CollectionProps::new().select(SelectMode::Single).activate(ActivateOn::Click),
}
.label(label)
}
+16 -2
View File
@@ -193,11 +193,11 @@ impl Rig {
self.panel.borrow().installed().iter().any(|f| f.name == family)
}
/// Opens the details of the card named `family`: the card takes the focus, Enter opens it.
/// Opens the details of the card named `family` with a click.
fn open(&mut self, family: &str) {
let card = self.named(Role::LIST_ITEM, family);
self.fx.click_at(Pos2::new(card.rect.left() + 4.0, card.rect.top() + 4.0));
self.key(Key::Enter);
self.fx.settle();
assert_eq!(self.panel.borrow().details_family().as_deref(), Some(family));
}
}
@@ -335,6 +335,20 @@ fn each_family_keeps_its_system_fonts_choice_across_starts() {
assert_eq!(again.store.calls().len(), 2);
}
/// A single click on a card's name area opens its details; a click on its Install control does only its own thing.
#[trial]
fn a_single_click_on_a_card_opens_its_details() {
let mut rig = setup("card-click");
rig.allow();
rig.type_into("Search", "Hack");
rig.click("Install");
assert_eq!(rig.panel.borrow().details_family(), None, "a press on a card's control opens no details");
let card = rig.named(Role::LIST_ITEM, "Hack");
rig.fx.click_at(Pos2::new(card.rect.left() + 4.0, card.rect.top() + 4.0));
rig.fx.settle();
assert_eq!(rig.panel.borrow().details_family().as_deref(), Some("Hack"));
}
/// A card's Install menu installs for the choice picked, and the press on it opens no details.
#[trial]
fn a_cards_install_menu_chooses_where_the_fonts_go() {