MCPcopy Index your code
hub / github.com/python/cpython / text_auto_scroll

Method text_auto_scroll

Lib/idlelib/sidebar.py:226–243  ·  view source on GitHub ↗

Mimic Text auto-scrolling when dragging outside of it.

()

Source from the content-addressed store, hash-verified

224 self.main_widget.bind('<B1-Motion>', b1_drag_handler)
225
226 def text_auto_scroll():
227 """Mimic Text auto-scrolling when dragging outside of it."""
228 # See: https://github.com/tcltk/tk/blob/064ff9941b4b80b85916a8afe86a6c21fd388b54/library/text.tcl#L670
229 nonlocal auto_scrolling_after_id
230 y = last_y
231 if y is None:
232 self.main_widget.after_cancel(auto_scrolling_after_id)
233 auto_scrolling_after_id = None
234 return
235 elif y < 0:
236 self.text.yview_scroll(-1 + y, 'pixels')
237 drag_update_selection_and_insert_mark(y)
238 elif y > self.main_widget.winfo_height():
239 self.text.yview_scroll(1 + y - self.main_widget.winfo_height(),
240 'pixels')
241 drag_update_selection_and_insert_mark(y)
242 auto_scrolling_after_id = \
243 self.main_widget.after(50, text_auto_scroll)
244
245 def b1_leave_handler(event):
246 # Schedule the initial call to text_auto_scroll(), if not already

Callers

nothing calls this directly

Calls 4

after_cancelMethod · 0.80
yview_scrollMethod · 0.80
winfo_heightMethod · 0.80
afterMethod · 0.80

Tested by

no test coverage detected