From 832701e48b6098c13d03490187cd6ce18df3af5b Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sun, 22 Nov 2026 08:20:27 +0700 Subject: [PATCH] pages: PageListEvent::rename, lock and new_row build the struct events outside the crate --- crates/pages/src/ui/list.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/pages/src/ui/list.rs b/crates/pages/src/ui/list.rs index 05b13067f..218121ea3 100644 --- a/crates/pages/src/ui/list.rs +++ b/crates/pages/src/ui/list.rs @@ -142,6 +142,23 @@ pub enum PageListEvent { ContextMenu(ContextMenuRequest), } +impl PageListEvent { + /// A name typed in place for `row`, which the list gives trimmed and never empty. + pub fn rename(row: usize, text: impl Into) -> Self { + Self::Rename { row, text: text.into() } + } + + /// A click on `row`'s lock, `locked` after the click. + pub const fn lock(row: usize, locked: bool) -> Self { + Self::Lock { row, locked } + } + + /// New, duplicating `duplicate` when a row was dropped on it; `options` with Alt held. + pub const fn new_row(duplicate: Option, options: bool) -> Self { + Self::New { duplicate, options } + } +} + /// The list's result. #[derive(Debug)] #[must_use = "the app applies the list's events"]