Slider Control

Is the slider in Xojo native (OSX)?

Yes, Slider = NSSlider. The only ones I know of that aren’t are Listbox <> NSTableView and OpenGLSurface <> NSOpenGLView.

we have a NSSliderMBS class and as you can query the NSSliderMBS for a slider control. This way you can access a lot of extra methods.

So I am having a problem then changing the slider type to circular dial. In the open even I have:


const NSLinearSlider   = 0
const NSCircularSlider = 1
declare sub setSliderType lib "Cocoa" selector "setSliderType:" ( handle as integer, value as integer )

setSliderType(me.handle,NSCircularSlider)

However I am getting the error:

-[XOJSlider setSliderType:]: unrecognized selector sent to instance 0x6eb2c0

Mike, you’re almost there - NSSlider has a NSSliderCell, and that’s the object that you want to send setSliderType to.

This will do it:

[code]const NSLinearSlider = 0
const NSCircularSlider = 1
declare sub setSliderType lib “Cocoa” selector “setSliderType:” ( handle as integer, value as integer )

declare function cell lib “Cocoa” selector “cell” (obj as integer) as integer

setSliderType(cell(me.handle), NSCircularSlider)[/code]

[quote=107823:@Gavin Smith]Mike, you’re almost there - NSSlider has a NSSliderCell, and that’s the object that you want to send setSliderType to.

This will do it:

const NSLinearSlider = 0 const NSCircularSlider = 1 declare sub setSliderType lib "Cocoa" selector "setSliderType:" ( handle as integer, value as integer ) declare function cell lib "Cocoa" selector "cell" (obj as integer) as integer setSliderType(cell(me.handle), NSCircularSlider)[/quote]

that works, but it does not look good.
Is there a way to change it?

Make the control taller in the IDE. It’s getting clipped.

This has no effect,
no matter what size, the result is always the same.

Xojo is doing something to size the control for vertical or horizontal. I think you’ll need to set the size via declare to bypass that. After Gavins code add…

declare sub setFrameSize lib "Cocoa" selector "setFrameSize:" (obj as integer, size As NSSize) dim s As NSSize s.width = 32 s.height = 32 setFrameSize(me.Handle, s)

and add

Structure NSSize width As single height As single

Thank You! That works.

Axel, I will update this on Xippets site, I note your comment regarding the clipping.

The last problem

I use in MouseWheel

me.Value = me.Value - deltaY
Return True

works fine, but the start point is then at top.