Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 31a4c22

Browse files
committed
added support for live feedback in scrollbars
1 parent cae6da6 commit 31a4c22

1 file changed

Lines changed: 11 additions & 27 deletions

File tree

Mac/Tools/IDE/Wcontrols.py

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,11 @@ class Scrollbar(ControlWidget):
295295

296296
"""Standard scrollbar."""
297297

298-
def __init__(self, possize, callback = None, value = 0, min = 0, max = 0):
299-
procID = Controls.scrollBarProc
298+
def __init__(self, possize, callback=None, value=0, min=0, max=0, livefeedback=1):
299+
if livefeedback:
300+
procID = Controls.kControlScrollBarLiveProc
301+
else:
302+
procID = Controls.scrollBarProc
300303
ControlWidget.__init__(self, possize, "", procID, callback, value, min, max)
301304

302305
# interface
@@ -373,34 +376,15 @@ def getmax(self):
373376
def click(self, point, modifiers):
374377
if not self._enabled:
375378
return
376-
# custom TrackControl. A mousedown in a scrollbar arrow or page area should
377-
# generate _control hits as long as the mouse is a) down, b) still in the same part
378-
part = self._control.TestControl(point)
379-
if Controls.inUpButton <= part <= Controls.inPageDown:
380-
self._control.HiliteControl(part)
381-
self._hit(part)
382-
oldpart = part
383-
# slight delay before scrolling at top speed...
384-
now = Evt.TickCount()
385-
while Evt.StillDown():
386-
if (Evt.TickCount() - now) > 18: # 0.3 seconds
387-
break
388-
while Evt.StillDown():
389-
part = self._control.TestControl(point)
390-
if part == oldpart:
391-
self._control.HiliteControl(part)
392-
self._hit(part)
393-
else:
394-
self._control.HiliteControl(0)
395-
self.SetPort()
396-
point = Evt.GetMouse()
397-
self._control.HiliteControl(0)
398-
elif part == Controls.inThumb:
399-
part = self._control.TrackControl(point)
379+
def hitter(ctl, part, self=self):
400380
if part:
401381
self._hit(part)
382+
part = self._control.TrackControl(point, hitter)
383+
if part:
384+
self._hit(part)
402385

403386
def _hit(self, part):
387+
value = None
404388
if part == Controls.inThumb:
405389
try:
406390
value = self._control.GetControl32BitValue()
@@ -416,7 +400,7 @@ def _hit(self, part):
416400
value = "++"
417401
elif part == Controls.inPageDown:
418402
value = "--"
419-
if self._callback:
403+
if value is not None and self._callback:
420404
Wbase.CallbackCall(self._callback, 1, value)
421405

422406
def draw(self, visRgn = None):

0 commit comments

Comments
 (0)