From 1d6e666335ee57afa6e96ab6e7cc2696347c8e52 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Thu, 2 Nov 2023 21:32:29 +1100 Subject: [PATCH] more stepper bits --- src/stepper/mod.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/stepper/mod.rs b/src/stepper/mod.rs index a3e36bc..6694b69 100644 --- a/src/stepper/mod.rs +++ b/src/stepper/mod.rs @@ -1,5 +1,6 @@ //! Implements a number stepper. By default this uses NSStepper on macOS. +use core_graphics::base::CGFloat; use core_graphics::geometry::CGRect; use objc::rc::{Id, Shared}; use objc::runtime::{Class, Object}; @@ -156,9 +157,18 @@ impl Stepper { }); } - /// Gets the selected index. - pub fn get_selected_value(&self) -> f32 { - self.objc.get(|obj| unsafe { msg_send![obj, floatValue] }) + /// Sets the selected value. + pub fn set_value(&self, value: f64) { + let value = value as CGFloat; + + self.objc.with_mut(|obj| unsafe { + let _: () = msg_send![obj, setDoubleValue: value]; + }); + } + + /// Gets the selected value. + pub fn get_value(&self) -> f64 { + self.objc.get(|obj| unsafe { msg_send![obj, doubleValue] }) } }