Page 1 of 1
ScrollBarGadget can't reach max?
Posted: Thu Dec 15, 2011 7:32 pm
by Trond
I just can't scroll to the end. Is this really right?
Code: Select all
W = 512
H = 384
OpenWindow(0, 0, 0, W, H, "", #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget)
ScrollBarGadget(0, 10, 10, 480, 17, 0, 100, 25)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Debug GetGadgetState(0) ; Never shows above 75
Case #PB_Event_CloseWindow
CloseWindow(0)
Break
EndSelect
ForEver
Re: ScrollBarGadget can't reach max?
Posted: Thu Dec 15, 2011 7:49 pm
by srod
Yes that is absolutely right.
The scrollbar you have set up would be appropriate for viewing say a text document with 100 lines (indexed 0 to 99). Because of your page size of 25 then the highest recordable scrollbar value would be 99 + 1 - 25 = 75. This is how the page-sizes work.
When the scrollbar state is 0 then your page size of 25 means that lines 0 to 0 + 25 -1 or lines 0 to 24 would be on view.
When the scrollbar state is 75 then your page size of 25 means that lines 75 to 75 + 25 -1 or lines 75 to 99 would be on view and this is exactly right.
Re: ScrollBarGadget can't reach max?
Posted: Fri Dec 16, 2011 1:06 am
by charvista
What srod answered is true...
I played with the code to see if I could display the percentage in
real time in the TextGadget while dragging the scrollbar. But no success... Only when I drop the mouse button, the percentage is showed.
The reason is to be able to see
when I should drop the mouse button.
Thanks
Code: Select all
W = 512
H = 384
Win=OpenWindow(#PB_Any,0,0,W,H,"",#PB_Window_ScreenCentered|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget)
TxGad=TextGadget(#PB_Any,10,40,100,20,"0")
SbGad=ScrollBarGadget(#PB_Any, 10, 10, 480, 17, 0, 100, 25)
Percent=0
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case SbGad
If EventType()=#PB_EventType_LeftClick ;does not work with #PB_EventType_Change
SetGadgetText(TxGad,Str(GetGadgetState(SbGad)))
EndIf
EndSelect
Case #PB_Event_CloseWindow
Quit=1
EndSelect
Until Quit=1
CloseWindow(Win)
Re: ScrollBarGadget can't reach max?
Posted: Tue Dec 20, 2011 4:59 pm
by DoubleDutch
Having 'live' events from the scroll bars has been requested - there are workarounds, but nothing 'native'.
Re: ScrollBarGadget can't reach max?
Posted: Tue Dec 20, 2011 6:55 pm
by charvista
Thank you DoubleDutch!!!
With your answer, I could make a search with the term "live" and "scrollbar" to find the fantastic solution from RASHAD (dumb up, my friend!) here:
http://www.purebasic.fr/english/viewtop ... nt#p353075
Cheers!
Re: ScrollBarGadget can't reach max?
Posted: Tue Dec 20, 2011 6:59 pm
by DoubleDutch
np.
You should +1 the request to add native support.
