Vertical Slider

Is it just me…
vertical slider control doesn’t display the background bar or the ticks when used on Mac?

Works fine horizontally, and vertically on Windows.
(My current Mac system is OSX 10.12 and Xojo 2015 R3)

Vertical Sliders don’t seem to work AT ALL anymore
seems with 10.12 any app that has, or is created with a Vertical slide, all you get it the “thumb”

Check out the docs for the Slider

In 10.12 you need to include the following in the Open event:

Declare Sub setVertical Lib "Cocoa" Selector "setVertical:" (windowRef As Integer, id As Boolean) setVertical(Me.Handle, True)

Thanks…
remember that Older programs where the Vertical Slider worked at the time they were compiled… Wont’ work anymore
So unless you have the source code,

Ouch.
It’s a constant battle.

[quote=369491:@Jeff Tullin]Ouch.
It’s a constant battle.[/quote]
yeah I found that out the hard way, with an MSPaint clone I wrote years and years ago… that used Vertical Sliders
I DO have the source code… but wasn’t aware of this “fix” until just now :slight_smile:

Note that older versions of macOS prior to Sierra don’t seem to like the declare for vertical slider. In one of my apps I had to use a conditional based on version to avoid a crash.

[quote=369498:@Michel Bujardet]Declare Sub setVertical Lib “Cocoa” Selector “setVertical:” (windowRef As Integer, id As Boolean)
setVertical(Me.Handle, True)[/quote]

This SHOULD work (I haven’t test it, but it is based on other declares I have for Sierra Tabbing)

#If TargetCocoa
   Declare Function NSClassFromString Lib "Cocoa" (s As CFStringRef) As Ptr
   Declare Function NSSelectorFromString Lib "Cocoa" (s As CFStringRef) As Ptr
   Declare Function respondsToSelector Lib "Cocoa" selector "respondsToSelector:" (p As Ptr, sel As Ptr) As Boolean
   Dim nswCls As Ptr = NSClassFromString ("NSWindow")
   Declare Sub setVertical Lib "Cocoa" Selector "setVertical:" (windowRef As Integer, id As Boolean)
   If respondsToSelector (nswCls, NSSelectorFromString ("setVertical:")) Then setVertical(nswCls,, True)	
#EndIf

Close — there were a couple of typos in that, fixed here:

#if TargetCocoa Declare Function NSClassFromString Lib "Cocoa" (s As CFStringRef) As Ptr Declare Function NSSelectorFromString Lib "Cocoa" (s As CFStringRef) As Ptr Declare Function respondsToSelector Lib "Cocoa" selector "respondsToSelector:" (p As Integer, sel As Ptr) As Boolean Declare Sub setVertical Lib "Cocoa" Selector "setVertical:" (objRef As Integer, value As Boolean) if respondsToSelector(me.Handle, NSSelectorFromString ("setVertical:")) then setVertical me.Handle, true #endif

It seems really unfortunate that we all have to do this now. The framework should be doing it for us under the hood when the height is greater than the width — this should not be our problem. As it is, if you just try to use a slider in a way that works on Windows, older versions of MacOS, and probably other platforms, It Just Doesn’t Work ™. And if you read the docs and do what it says there, then your app will work on 10.12 or later, but throw an exception on 10.11 or earlier. Not very friendly, is it?

I realize that this thread is a few months old… but I have been playing with Swift and OSX, and decided to test an assumption.

Seems that macOS (in this case High Sierra) the slider still works EXACTLY like it used to work in Xojo. You “can” force it to be vertical using code similar to above… but if the HEIGHT is greater than the WIDTH, it changes to vertical.
So if Apple seems to have not changed the underlying functions… why did it stop working in Xojo???

Don’t assume that because it works in Swift, it’s not broken. Remember Swift is just like Xojo, it;s a higher level development tool that requires a ton of frameworks to make it work. It’s possible that Apple have written a workaround in the Swift framework, but left it broken in the OS.

For example, there was a bug in CoreImage that rendered a simple function unusable, but the bug doesn’t present it’self in Apple’s Photos, because the Photos guys simply worked around it, rather than getting the OS guys to fix it. Leaving it broke for all 3rd party developers.

Try comparing with Objective-C, it’s a lower level language and in theory more likely to give you closer to OS results.