Mac OS - Live ScrollBar, pleaaaase

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Niffo
Enthusiast
Enthusiast
Posts: 500
Joined: Tue Jan 31, 2006 9:43 am
Location: France

Mac OS - Live ScrollBar, pleaaaase

Post 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
Niffo
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Mac OS - Live ScrollBar, pleaaaase

Post 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!
User avatar
DoubleDutch
Addict
Addict
Posts: 3219
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: Mac OS - Live ScrollBar, pleaaaase

Post by DoubleDutch »

It would be very handy on Windows too! (don't know if it is possible though).
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Mac OS - Live ScrollBar, pleaaaase

Post 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 :)
User avatar
DoubleDutch
Addict
Addict
Posts: 3219
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: Mac OS - Live ScrollBar, pleaaaase

Post 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'.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: Mac OS - Live ScrollBar, pleaaaase

Post 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.)
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Mac OS - Live ScrollBar, pleaaaase

Post 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 ;)
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: Mac OS - Live ScrollBar, pleaaaase

Post by kenmo »

Ah okay. I think ProgressBarGadgets do that, right? I rarely use ScrollBarGadgets, but that would definitely be useful on all platforms.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Mac OS - Live ScrollBar, pleaaaase

Post by Polo »

Can the live scrollbar on the mac be enabled for 4.60 final please?
It only requires to add a flag ! :)
Lebostein
Addict
Addict
Posts: 807
Joined: Fri Jun 11, 2004 7:07 am

Re: Mac OS - Live ScrollBar, pleaaaase

Post 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:
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Mac OS - Live ScrollBar, pleaaaase

Post 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
Windows (x64)
Raspberry Pi OS (Arm64)
Lebostein
Addict
Addict
Posts: 807
Joined: Fri Jun 11, 2004 7:07 am

Re: Mac OS - Live ScrollBar, pleaaaase

Post by Lebostein »

Thanks! I miss a hint in documentation on page TrackBarGadget() and ScrollBarGadget(). A small section with a link to BindEvent....
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Mac OS - Live ScrollBar, pleaaaase

Post 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.
Windows (x64)
Raspberry Pi OS (Arm64)
Post Reply