You can even override the scroller drawing and customize the scrollers:
[code]declare function object_getClass lib CocoaLib (id as Ptr ) as Ptr
declare function class_replaceMethod lib CocoaLib (cls as ptr, name as ptr, imp as ptr, types as CString) as ptr
dim scroller as ptr = object_getClass(verticalScroller(self.viewRef))
dim p as ptr = class_replaceMethod(scroller, NSSelectorFromString(“drawKnobSlotInRect:highlight:”), AddressOf dispatch_DrawSlot, “v@:@b”)
Private Shared Sub dispatch_DrawSlot(pid as ptr, sel as ptr, rect as NSRect, highlight as Boolean)
End Sub[/code]
[quote=236236:@Richard Berglund]From using the example project, delete the ClippingContainer from the window in the IDE, then adding it from in the constructor or open event.
dim cc as new ClippingContainerControl
cc.EmbedWithin(self, 0,0,self.width,self.height)
Scrolling works but scrollbars don’t show up.[/quote]
I have not issues: (open event mainwindow)
dim cc as new ClippingContainerControl
cc.EmbedWithin(ScrollViewWIndow, 0,0)
self.ccRef=cc
You need to make sure clipping container is smaller than content container (scrollerContainer) otherwise
Scroller doesn’t show because there no content to scroll.
With your code you expand the clip to the main window size which exceeds scrollerContainer size
and therefore no scrolling is needed.
cc.EmbedWithin(self, 0,0,self.width,self.height)
#Edit:
Updated the example: scrollToBottom works correctly.
Its the XScrollview thats a little sensitive Got my way finally.
dim cc as new ClippingContainerControl(new ScrolledContainerControl)
cc.EmbedWithin(self,0,0,self.width,self.height)
cc.myContainer.EmbedWithin(self, 0,0)
cc.myScrollView=new XScrollView(self,cc.myContainer)
AddHandler cc.myScrollView.Magnify,AddressOf cc.HandleMagnify
cc.LockTop=true
cc.LockLeft=true
cc.LockRight=true
cc.LockBottom=true
There is a serious issue when using Jims declares. It disables mouse click throughs. So when the main window is not active and you click on the control that uses Jims declares, it does not receive the click. So the user will have first active the window and then click on the control. Which is not how OSX apps behave (and I do get a lot of users complaining about this).
I asked Jim to take a look at this. Hoping for the fix/improvement for this.
The standard in Cocoa is not to click through (even if most applications implement it nowadays). So the comment “serious issue” was a bit unfair towards Jim.
I have a question for the obj-c programmers among us: I have added custom a paint event for the knob and slot by overriding
the scrollers methods but I am not sure if there’s a simpler way ? (although it works fine).