vertical slider does not work

Hello,
I just noticed that vertical sliders (in my case 23 width x 110 high) in desktop apps do not work anymore: only the “knob” appears, always at the center; no way to drag the knob anywhere else.

Using Xojo 2016v1 with Sierra (10.12.13). I may be wrong, but I’m pretty sure the issue did not appear with Yosemite.

Has anybody encountered the problem and solved it?
Regards,
Carlo

Sometimes, using search would greatly help :
https://forum.xojo.com/37981-vertical-slider-broken-under-macos-sierra/0

Sorry, really.
Actually I did use search, but I missed that particular post.
Thank you, and to Urlich for the workaround.

Make sure to use conditional execution for previous versions of the system. Ulrich class is not compatible with less than Sierra.

I personally shell to

sw_vers 

There other, various methods around. That one has the advantage to work with the very latest versions. There a wealth of methods in the forum, but they are stuck at their time of publication.

Thank you for the advice.

I’m a bit surprised to read that: Vertical is a property that exists in NSSlider right from the start, at least according to Apple’s docs. That workaround does not do anything more than to set this property. What happens when you use it with an older macOS?

It crashes. I solved the issue by placing a regular vertical slider on the window. If >= 10.12 I make it invisible, and embed a ContainerControl with your vertical slider.

Actually, I assumed the same as you and published Fonts Manager with it, until I got a very angry customer messaging in that the app did not work under EC.

Weird! Any hints in the crash log – unknown selector or something like that?

I am sorry, it has been a while, I don’t remember. I verified it under EC but that was a while ago.

OK. I tried a new test app under EC, and it works. Could have been additional code that triggered the issue.

Thanks, Michel! I am usually quite careless with regards to older versions, but in this case I kept wondering if Apple changed the property without further notice. In a way the documentation was a bit misleading because isVertical is indeed an Integer, not a Boolean, with 0 = False, 1 = True and –1 = undefined.

Ulrich, Apple Store’s reviewer rejected my app using your workaround. I asked him if he could tell me which system-versions were involved. The answer was: crash in 10.10.5; OK for all the other versions.
Therefore, at least we know that it can be succesfully used from 10.10.5 up.
Thank you again.

Since I cannot edit my last post, I wanted to add that in order to use the workaround it is enough to check its get/set Vertical property:

Get
#if TargetMacos
if IsSierra then
return getVertical (me.Handle)
end if
#endif
End Get

where isSierra is a function I added to macoslibrary:
Function IsSierra() As Boolean
return SystemVersionAsInt >= 101200
End Function

Regards.

What is SystemVersionAsInt ? Could you post the code ?

It is a function in macoslibrary in the Carbon section:

Function SystemVersionAsInt() As Integer
// The value returned is scaled up, so that a version like 10.1.2 becomes 100102, i.e. two digits per part.
//
// This function avoids using floating point, so that a version such as 10.4 doesn’t become 10.39999 or something alike, making a test for >=10.4 fail

#if TargetMacOS
static version as Integer

if version = 0 then
  // Since OSX 10.10, we have to prefer NSProcessInfo's version over Gestalt
  dim sys1, sys2, sys3 as Integer
  dim v as NSProcessInfo.OSVersion
  v = NSProcessInfo.ProcessInfo.OperatingSystemVersion
  if v.major > 0 then
    sys1 = v.major
    sys2 = v.minor
    sys3 = v.patch
  else
    // This OS is older (pre 10.9), so we'll fall back to using Gestalt
    call System.Gestalt("sys1", sys1)
    call System.Gestalt("sys2", sys2)
    call System.Gestalt("sys3", sys3)
  end if
  version = 10000 * sys1 + 100 * sys2 + sys3
end if

return version

#endif
End Function

Thank you.

If you don’t want to employ MacOSLib for simply getting the version, here’s a quickly created stand-alone class that should run on iOS too.

EDIT: Apple Dev Center says the version info works from 10.2 on, so I see no need to fall back to Gestalt.