Is it possible to change the TrackBarGadget behaviour for Windows in that way, that the position slider jumps exakt at the position I click on the bar? At the moment It seems the trackbar is splited in 5 to 7 "pages" and if I click on the bar the slider moves to the next "page" only in the direction of the mouse pointer. Very strange for some uses.
With Mac OS I hove not this problem. The slider jumps exactly to the mouse pointer if I click on the bar....
Changing TrackBarGadget behaviour
Re: Changing TrackBarGadget behaviour
Have you already tried out hjbremer's example in the German forum?
Re: Changing TrackBarGadget behaviour
Thanks for the link, Shardik. Saved for the future because I know I'll need it one day.
Re: Changing TrackBarGadget behaviour
Thanks, it works, but very laggy and unprecies. Are there other Gadgets from the API they can Do that? This page wise behaviour is useful for scrollbars, but not for trackbars in my eyes. Maybe IT could help to overwrite that huge page size value....
Re: Changing TrackBarGadget behaviour
See if that of any help
Edit : Copy & Paste bugs
Code: Select all
#TBS_TOOLTIPS = $100
If OpenWindow(0, 0, 0, 320, 200, "TrackBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TextGadget (3, 10, 20, 250, 20,"TrackBar Standard", #PB_Text_Center)
TrackBarGadget(0, 10, 40, 300,50, 0, 30,#PB_TrackBar_Ticks|#TBS_TOOLTIPS |#TBS_FIXEDLENGTH )
SetGadgetState(0, 15)
SendMessage_(GadgetID(0), #TBM_SETTHUMBLENGTH,25,0)
SendMessage_(GadgetID(0), #TBM_SETPAGESIZE ,0,1)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 0
If GetAsyncKeyState_(#VK_LBUTTON)
GetCursorPos_ (@p.POINT)
ScreenToClient_ (GadgetID(0), @p)
SetGadgetState(0, (p\x-13)/9) ; 9 = (GadgetWidth - 40)/Maximum State
EndIf
EndSelect
EndSelect
Until Quit = 1
EndIf
Egypt my love
Re: Changing TrackBarGadget behaviour
Thanks! Works very well!
Here is the condensed version. Works with every GadgetWidth and any maximum value (minimum = 0):
Here is the condensed version. Works with every GadgetWidth and any maximum value (minimum = 0):
Code: Select all
#Trackbar = 0
#dist_L = 12 ; measured on Windows 10
#dist_R = 13 ; measured on Windows 10
OpenWindow(0, 0, 0, 320, 200, "TrackBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TrackBarGadget(#Trackbar, 10, 40, 300,50, 0, 255)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow: Break
Case #PB_Event_Gadget
Select EventGadget()
Case #Trackbar
; -----> that is the trick
GetCursorPos_(@click.POINT)
ScreenToClient_(GadgetID(#Trackbar), @click)
pos = Round((click\x - #dist_L) / (GadgetWidth(#Trackbar) - #dist_L - #dist_R) * GetGadgetAttribute(#Trackbar, #PB_TrackBar_Maximum), #PB_Round_Nearest)
SetGadgetState(#Trackbar, pos)
; <----- end of trick
EndSelect
EndSelect
ForEver