mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 05:37:04 +00:00
rc-chrome-w6: S-L187 edit signal (red round 1b)
This commit is contained in:
@@ -672,9 +672,11 @@ fn expand_for_overflow(ui: &mut Ui, at: ShowAt, rect: Rect, overflow: f32, rtl:
|
||||
}
|
||||
|
||||
/// What the component senses itself: a disabled one that shows a reason on focus stays a Tab stop and senses nothing else.
|
||||
/// One bound to an edit command keeps the focus where it is on a press, so the edit reaches the focused component.
|
||||
fn own_sense(e: &dyn ErasedPass<'_>, resolved: &Resolved, inert: bool) -> Sense {
|
||||
match (inert, resolved.enabled) {
|
||||
(true, _) => Sense::HOVER,
|
||||
(false, true) if resolved.command.is_some_and(|command| command.edit) => e.sense().difference(Sense::TAKE_FOCUS).union(Sense::KEEP_FOCUS),
|
||||
(false, true) => e.sense(),
|
||||
(false, false) if steps::takes_focus(resolved) => Sense::HOVER | e.comp_sense().intersection(Sense::FOCUS),
|
||||
(false, false) => Sense::HOVER,
|
||||
|
||||
@@ -414,6 +414,7 @@ impl Board {
|
||||
marked: state.is_some_and(CommandState::is_marked),
|
||||
hint: state.and_then(|s| s.hint_ref().cloned()),
|
||||
kind: def.map_or(CommandKind::Command, |def| def.kind.clone()),
|
||||
edit: self.registry.edit_of(&command.id).is_some(),
|
||||
command: command.clone(),
|
||||
instance,
|
||||
};
|
||||
|
||||
@@ -276,6 +276,9 @@ pub struct ResolvedCommand {
|
||||
pub hint: Option<Arc<str>>,
|
||||
/// What the command is.
|
||||
pub kind: CommandKind,
|
||||
/// The command is an edit a focused component takes as its own (it has an `EditCommand` link): a control bound to
|
||||
/// it keeps the focus where it is on a press, so the edit reaches the focused component.
|
||||
pub edit: bool,
|
||||
pub(crate) command: CommandRef,
|
||||
#[doc(hidden)]
|
||||
pub instance: Option<Id>,
|
||||
|
||||
@@ -383,7 +383,9 @@ impl Component for BarItems {
|
||||
slot(rect, axis, rtl, from, more_length)
|
||||
});
|
||||
for &(index, cell) in &shown {
|
||||
let part = cx.part(ITEM.at(index as u64), cell).sense(Sense::CLICK | Sense::FOCUS).focusable();
|
||||
// An edit command's item keeps the focus where it is, so the edit reaches the focused component.
|
||||
let sense = if present[index].resolved.edit { Sense::CLICK | Sense::FOCUS | Sense::KEEP_FOCUS } else { Sense::CLICK | Sense::FOCUS };
|
||||
let part = cx.part(ITEM.at(index as u64), cell).sense(sense).focusable();
|
||||
if display_of(&present[index]) == ItemDisplay::Icon {
|
||||
let resolved = &present[index].resolved;
|
||||
part.tooltip(match &resolved.chord {
|
||||
|
||||
Reference in New Issue
Block a user