From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id AA86F1FF16F for ; Tue, 24 Jun 2025 14:18:56 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D81CA367CD; Tue, 24 Jun 2025 14:19:30 +0200 (CEST) From: Dominik Csapak To: yew-devel@lists.proxmox.com Date: Tue, 24 Jun 2025 14:19:24 +0200 Message-Id: <20250624121925.57056-11-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250624121925.57056-1-d.csapak@proxmox.com> References: <20250624121925.57056-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.022 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [yew-devel] [PATCH yew-widget-toolkit 6/7] touch: slidable: add on_tap callback X-BeenThere: yew-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Yew framework devel list at Proxmox List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Yew framework devel list at Proxmox Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: yew-devel-bounces@lists.proxmox.com Sender: "yew-devel" simply exposing the callback of the same name of the underlying gesture detector. Signed-off-by: Dominik Csapak --- src/touch/slidable/mod.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/touch/slidable/mod.rs b/src/touch/slidable/mod.rs index ffcf8c8..6802426 100644 --- a/src/touch/slidable/mod.rs +++ b/src/touch/slidable/mod.rs @@ -43,6 +43,12 @@ pub struct Slidable { /// Without a callback, dismiss is disabled on slidables without actions. #[prop_or_default] pub on_dismiss: Option>, + + #[prop_or_default] + /// Tap callback. + /// + /// Called when the main item is tapped. + pub on_tap: Option>, } impl Slidable { @@ -80,6 +86,17 @@ impl Slidable { self.on_dismiss = cb.into_event_callback(); self } + + /// Builder style method to set the `on_tap` callback. + pub fn on_tap(mut self, cb: impl IntoEventCallback) -> Self { + self.set_on_tap(cb); + self + } + + /// Method to set the `on_tap` callback. + pub fn set_on_tap(&mut self, cb: impl IntoEventCallback) { + self.on_tap = cb.into_event_callback(); + } } #[derive(Copy, Clone, Debug, PartialEq)] @@ -125,6 +142,7 @@ pub enum Msg { ContentResize(f64, f64), TransitionEnd, Controller(SlidableControllerMsg), + OnTap(InputEvent), } impl PwtSlidable { @@ -320,6 +338,11 @@ impl Component for PwtSlidable { } } }, + Msg::OnTap(pointer_event) => { + if let Some(on_tap) = &ctx.props().on_tap { + on_tap.emit(pointer_event); + } + } } let pos = self.start_pos - (self.drag_pos.unwrap_or(0) as f64); if pos > 0f64 { @@ -361,6 +384,7 @@ impl Component for PwtSlidable { .on_drag_start(ctx.link().callback(Msg::DragStart)) .on_drag_end(ctx.link().callback(Msg::DragEnd)) .on_drag_update(ctx.link().callback(Msg::Drag)) + .on_tap(ctx.link().callback(Msg::OnTap)) .on_swipe(ctx.link().callback(Msg::Swipe)); let left_container = Container::new() -- 2.39.5 _______________________________________________ yew-devel mailing list yew-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel