In a TextArea, I have the following declares in the .Open event to make it transparent.
Declare Sub setDrawBack Lib "Cocoa" selector "setDrawsBackground:"(id As Integer, b As Boolean)
Declare Function docView Lib "Cocoa" selector "documentView"(id As Integer) As Integer
setDrawBack(Me.Handle, False)
setDrawBack(docView(Me.Handle), False)
…that works and looks good.
However, a while ago, I found out that when on an iMac without a trackpad, the Scrollbar isn’t transparent.
In the below .gif you’ll see what I mean. It changes a few seconds after I switch off my trackpad.
Does anyone know a way how I can adjust my declares so this doesn’t happen?
I think this is an OS X thing. It is only transparent when a trackpad or a mouse is attached to the computer. Without a pointing device the user has no way to get the information from the scroller (in that case, how long the text is).
On my MacBook I can go to System Preferences > Accessibility and turn the trackpad off and the same thing happens.
Well, I forgot to mention that the mouse is still there.
I use both a regular logitech mouse and a trackpad. When I switch off my trackpad, the mouse is still active but it flips.
An iMac doesn’t come with a trackpad nowadays does it? I can’t remember.
So basically everyone with an iMac but without a trackpad sees the non-transparent Scrollbar?
You can disable the “Scroller Slot” drawing app-wide by modifying the Cocoa NSScroller Class.
If you want to disable it for specific controls, you would create a subclass of NSScroller (that overrides drawKnobSlotInRect:highlight:) and set an instance of the subclass as verticalScroller and horizontalScroller on each control. Somewhat more involved, but I can post a snippet here also if you like.
For this code, “drawknobslotinrect()” is a global method that does nothing, just to prevent drawing the background “slot”.
declare function NSClassFromString lib "Foundation" (classname as CFStringRef) as ptr
declare function NSSelectorFromString lib "Foundation" (aSelectorName as CFStringRef) as Ptr
declare function class_replaceMethod lib "/usr/lib/libobjc.dylib" (cls as ptr, name as Ptr, imp as Ptr, types as CString) as ptr
call class_replaceMethod(NSClassFromString("NSScroller"),NSSelectorFromString("drawKnobSlotInRect:highlight:"),addressof drawknobslotinrect,"")
SOP - mess with it and you’ll may upset users. My wife prefers to see the scrollbars all the time. That’s how she rolls on her Mac.
Don’t forget that Apple has a system wide preference for this and you should respect it, even if it’s just to conform with the other applications that do.
[quote=238235:@Sam Rowlands]SOP - mess with it and you’ll may upset users. My wife prefers to see the scrollbars all the time. That’s how she rolls on her Mac.
Don’t forget that Apple has a system wide preference for this and you should respect it, even if it’s just to conform with the other applications that do.
Anyhoe, just my 2¢[/quote]
Agreed. I also keep scrollbars visible all the time and would find an app that unconditionally hides them to be frustrating.
[quote=238257:@Joe Ranieri]Agreed. I also keep scrollbars visible all the time and would find an app that unconditionally hides them to be frustrating.
[/quote]
I would too, but we’re not hiding the scrollers here…
[quote=238273:@Michel Bujardet]Not sure it is feasible, but showing them only when the cursor gets to the right of the control or when the wheel is moved would be very nice.
[/quote]
That might be more confusing to the user…
Here is code that will draw the tracks in a translucent manner that flows with the look OP was going for, but still follows Apple’s HIG.
Seems like a better idea than simply obliterating the drawing all together.
(to be placed in a module, NOT as a method in a window)
[code]Sub drawKnobSlotInRect(obj as ptr, sel as ptr, rect as cgrect, highlight as Boolean)
Declare function NSClassFromString lib “Foundation” (classname as CFStringRef) as ptr
Declare Function colorWithWhitealpha Lib “AppKit” selector “colorWithWhite:alpha:” _
(classref As ptr,white as CGFloat,alpha as CGFloat) As ptr
Declare sub fillRect Lib “AppKit” selector “fillRect:” (classref As ptr,rect as cgrect)
Declare sub set Lib “AppKit” selector “set” (obj As ptr)
[quote=238291:@jim mckay]Here is code that will draw the tracks in a translucent manner that flows with the look OP was going for, but still follows Apple’s HIG.
Seems like a better idea than simply obliterating the drawing all together.[/quote]
Wouldn’t it better to use either the correct color or to draw the actual slider track. White may work for Aqua appearance, but it will not work in dark Aqua, or any other Aqua that Apple might invent in the next few months.
I’m not sure what you mean. Marco was trying to eliminate the odd appearance of the opaque slider track. The code above just draws the slider track translucent so it works better with his dark background textarea. Not sure what you mean by “Dark Aqua”…