mojbro / gocoa

Go bindings for the Cocoa framework to build macOS applications
MIT License
68 stars 17 forks source link

Implement Sliders #19

Closed StarHack closed 3 years ago

StarHack commented 3 years ago

This is an initial implementation of a Slider component.

// label
label := gocoa.NewLabel(165, 130, 300, 50)
label.SetStringValue("test")
wnd.AddLabel(label)

// slider
slider := gocoa.NewSlider(25, 125, 300, 150)
slider.SetMaximumValue(10.0)
slider.SetMinimumValue(1.0)
slider.SetValue(2.5)
slider.SetSliderType(gocoa.SliderTypeLinear)
slider.OnSliderValueChanged(func() {
    sliderVal := fmt.Sprintf("%f", slider.Value())
    label.SetStringValue(sliderVal)
})
wnd.AddSlider(slider)
example-slider