Page 1 of 1

Mac OS - Live ScrollBar, pleaaaase

Posted: Thu Mar 10, 2011 8:16 pm
by Niffo
Pleaaase, is it possible to set the parameter "liveTracking" to "True" when calling the CreateScrollBarControl() API from the Gadget library of PB ? ... so that we can have a "Live ScrollBar" when using the SetControlAction() API to assign a callback function to it.

This already works with PB "TrackBar Gadget", so i assume it is created with the CreateSliderControl() API with the "liveTracking" parameter set to "True".

Code sample to illustrate this (try to drag the sliders/scrollbars) :

Code: Select all

ImportC "/System/Library/Frameworks/Carbon.framework/Carbon"
   NewControlActionUPP.l(*userRoutine)
   SetControlAction(theControl.l, actionProc.l)
   CreateScrollBarControl(window.l, *boundsRect, value.l, minimum.l, maximum.l, viewSize.l, liveTracking.b, liveTrackingProc.l, *outControl)
   ShowControl(theControl.l)
EndImport

Structure Rect
   top.w
   left.w
   bottom.w
   right.w
EndStructure

OpenWindow(0, 100, 100, 500, 200, "Test")

TrackBarGadget(0, 10, 10, 200, 20, 0, 10)
TextGadget(1, 230, 10, 200, 20, "'normal' slider")

TrackBarGadget(2, 10, 50, 200, 20, 0, 10)
TextGadget(3, 230, 50, 200, 20, "'live' slider")

ScrollBarGadget(4, 10, 90, 200, 20, 0, 10, 1)
TextGadget(5, 230, 90, 200, 20, "'normal' scrollbar")

ScrollBarGadget(6, 10, 130, 200, 20, 0, 10, 1)
TextGadget(7, 230, 130, 200, 20, "'live' scrollbar (does not work)")

Rect.Rect : Rect\left = 10 : Rect\top = 170 : Rect\right = 210 : Rect\bottom = 190
CreateScrollBarControl(WindowID(0), @Rect, 0, 0, 10, 1, #True, #Null, @APIScrollBar)
ShowControl(APIScrollBar)
TextGadget(8, 230, 170, 200, 20, "API created 'live' scrollbar")

ProcedureCDLL LiveTrackingProc()
EndProcedure

ControlActionUPP = NewControlActionUPP(@LiveTrackingProc())
SetControlAction(GadgetID(2), ControlActionUPP)
SetControlAction(GadgetID(6), ControlActionUPP)
SetControlAction(APIScrollBar, ControlActionUPP)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

Re: Mac OS - Live ScrollBar, pleaaaase

Posted: Tue Sep 13, 2011 7:41 pm
by Polo
Hi,

Not that I want to bump this topic (well, I did, sorry :oops: ) but this change would save me a lot of API calls, and only requires a 5 second fix from PB team :)
Thanks in advance!

Re: Mac OS - Live ScrollBar, pleaaaase

Posted: Wed Sep 14, 2011 11:23 pm
by DoubleDutch
It would be very handy on Windows too! (don't know if it is possible though).

Re: Mac OS - Live ScrollBar, pleaaaase

Posted: Thu Sep 15, 2011 12:03 am
by Polo
DoubleDutch wrote:It would be very handy on Windows too! (don't know if it is possible though).
Yes, with a workaround (available on this forum), like on MacOSX, but in order to do the Mac workaround the PB scrollbars need to be changed, hence the request :)

Re: Mac OS - Live ScrollBar, pleaaaase

Posted: Thu Sep 15, 2011 1:20 am
by DoubleDutch
Having live scroll bars makes it possible to do some very interesting canvasgadget work. For example I've done a word-wrapping tree gadget that works directly from my packed data - I've no need to load the tree as it renders directly.

Image
http://ɯoɔ.com/images/tree.jpg

I use the live scroll bar routines that I found on the forum to allow the user to scroll up/down the tree, but if would be much nicer if it was 'native'.

Re: Mac OS - Live ScrollBar, pleaaaase

Posted: Thu Sep 15, 2011 11:24 pm
by kenmo
I'm missing the obvious here... what do you guys mean by "live" scrollbar? (Don't have a Mac or even PB available to test right now.)

Re: Mac OS - Live ScrollBar, pleaaaase

Posted: Fri Sep 16, 2011 12:29 am
by Polo
kenmo wrote:I'm missing the obvious here... what do you guys mean by "live" scrollbar? (Don't have a Mac or even PB available to test right now.)
When you scroll using the buttons, you receive an event when you release the button. We want the event when the position has changed (even if it's still changing).

And the specific request for Mac is that even though you move the scrollbar, it won't get moved until you release the button which is very non-standard ;)

Re: Mac OS - Live ScrollBar, pleaaaase

Posted: Fri Sep 16, 2011 12:33 am
by kenmo
Ah okay. I think ProgressBarGadgets do that, right? I rarely use ScrollBarGadgets, but that would definitely be useful on all platforms.

Re: Mac OS - Live ScrollBar, pleaaaase

Posted: Wed Oct 26, 2011 3:59 pm
by Polo
Can the live scrollbar on the mac be enabled for 4.60 final please?
It only requires to add a flag ! :)

Re: Mac OS - Live ScrollBar, pleaaaase

Posted: Thu Nov 09, 2017 6:42 am
by Lebostein
Any news about geting trackbar positions while sliding? At the moment on Mac OS all events are spitted out only if you release the trackbar... :cry:

Re: Mac OS - Live ScrollBar, pleaaaase

Posted: Thu Nov 09, 2017 7:26 am
by wilbert
Lebostein wrote:Any news about geting trackbar positions while sliding? At the moment on Mac OS all events are spitted out only if you release the trackbar... :cry:
Use BindEvent.

Code: Select all

Procedure Trackbar0Callback()
  Debug GetGadgetState(0)
EndProcedure

OpenWindow(0, 0, 0, 320, 200, "TrackBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TrackBarGadget(0, 10,  40, 250, 20, 0, 10000)
SetGadgetState(0, 5000)

BindEvent(#PB_Event_Gadget, @Trackbar0Callback(), 0, 0)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

Re: Mac OS - Live ScrollBar, pleaaaase

Posted: Thu Nov 09, 2017 9:49 am
by Lebostein
Thanks! I miss a hint in documentation on page TrackBarGadget() and ScrollBarGadget(). A small section with a link to BindEvent....

Re: Mac OS - Live ScrollBar, pleaaaase

Posted: Thu Nov 09, 2017 10:11 am
by wilbert
Lebostein wrote:Thanks! I miss a hint in documentation on page TrackBarGadget() and ScrollBarGadget(). A small section with a link to BindEvent....
It is mentioned on the BindEvent page
It also allows to have real-time event notifications as the callback can be invoked as soon as the event occurs (useful for ScrollBarGadget(), live window resize, etc.)
but I agree it would be nice to mention it on the TrackBarGadget and ScrollBarGadget pages as well.