more stepper bits

This commit is contained in:
Alex Janka 2023-11-02 21:32:29 +11:00
parent e7d057b193
commit 1d6e666335

View file

@ -1,5 +1,6 @@
//! Implements a number stepper. By default this uses NSStepper on macOS. //! Implements a number stepper. By default this uses NSStepper on macOS.
use core_graphics::base::CGFloat;
use core_graphics::geometry::CGRect; use core_graphics::geometry::CGRect;
use objc::rc::{Id, Shared}; use objc::rc::{Id, Shared};
use objc::runtime::{Class, Object}; use objc::runtime::{Class, Object};
@ -156,9 +157,18 @@ impl Stepper {
}); });
} }
/// Gets the selected index. /// Sets the selected value.
pub fn get_selected_value(&self) -> f32 { pub fn set_value(&self, value: f64) {
self.objc.get(|obj| unsafe { msg_send![obj, floatValue] }) 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] })
} }
} }