Recursively bind scroll events to widget and children. Skips any nested CTkScrollableFrame widgets since they handle their own scrolling independently.
(self, widget, target_scrollable)
| 1371 | self._bind_scroll_to_widget(scrollable_frame, scrollable_frame) |
| 1372 | |
| 1373 | def _bind_scroll_to_widget(self, widget, target_scrollable): |
| 1374 | """Recursively bind scroll events to widget and children. |
| 1375 | |
| 1376 | Skips any nested CTkScrollableFrame widgets since they handle |
| 1377 | their own scrolling independently. |
| 1378 | """ |
| 1379 | # Skip if this is a nested scrollable frame (not the target itself) |
| 1380 | # Let nested scrollable frames handle their own scrolling |
| 1381 | if widget is not target_scrollable and isinstance( |
| 1382 | widget, ctk.CTkScrollableFrame |
| 1383 | ): |
| 1384 | return |
| 1385 | |
| 1386 | if platform.system() == "Linux": |
| 1387 | widget.bind( |
| 1388 | "<Button-4>", lambda e: self._on_scroll(target_scrollable, -3), add="+" |
| 1389 | ) |
| 1390 | widget.bind( |
| 1391 | "<Button-5>", lambda e: self._on_scroll(target_scrollable, 3), add="+" |
| 1392 | ) |
| 1393 | else: |
| 1394 | widget.bind( |
| 1395 | "<MouseWheel>", |
| 1396 | lambda e: self._on_mousewheel(e, target_scrollable), |
| 1397 | add="+", |
| 1398 | ) |
| 1399 | |
| 1400 | # Recursively bind to children |
| 1401 | for child in widget.winfo_children(): |
| 1402 | self._bind_scroll_to_widget(child, target_scrollable) |
| 1403 | |
| 1404 | def _on_mousewheel(self, event, target): |
| 1405 | """Handle mouse wheel on Windows/macOS.""" |
no test coverage detected