Which component class should I use to change the behavior of a number_slider?

Is it special class or simply GH_Component with custom attributes?

Here as far as I understand ghpython is derived from a special type. Is there something special for sliders too?

image

Thanks in advance

That said, I would like to put things in order and leave the other thread for Galapagos. This one for Slider alteration.

Hi @DavidRutten,

I have a couple of questions about the GH_NumberSlider:

  • are the methods/attributes/properties inside it all public?
    Although since they don’t show in the autocomplete :frowning: I think I have my answer.
    image
    image

  • what are the names of the min and max values properties/methods?

The domain, value, etc. are properties of GH_NumberSlider.Slider. E.g. you can set GH_NumberSlider.Slider.Min and GH_NumberSlider.Slider.Max. If the current value of the slider is not inside the domain this will create funny graphic effects :slight_smile:

I think there were large posts regarding slider manipulation in the past, search the forum for GH_NumberSlider and you will find immediately.

Could you share how did you find these?

This shows up in my autocomplete… But I think GH_NumberSlider.Slider is a handle to GH_SliderBase which should be documented.

https://developer.rhino3d.com/api/grasshopper/html/T_Grasshopper_GUI_Base_GH_SliderBase.htm

Unfortunately, if I create a class derived from GH_SliderBase it will not be exactly like extending GH_NumberSlider, which ultimately will cause Galapagos to reject it. :frowning:

That’s part of another discussion, I think :wink:

Anyways, I was not suggesting to derive anything from GH_SliderBase. All I was saying is, that the properties you seem to be interested in (slider value, min value, max value, type etc.) are not properties of GH_NumberSlider, instead GH_NumberSlider carries an instance of GH_SliderBase which exposes the beforementioned properties. If you want to manipulate a slider, you can do so by getting a handle to a slider object on the canvas (which will be of type GH_NumberSlider) and access it’s Slider property.

1 Like