Tk Source Code

View Ticket
Login
Ticket UUID: 061bf93176a5684a4a855f8177b290c59dd39bf2
Title: Mac scrollbar slider visually off active area
Type: Bug Version: 8.6.4
Submitter: tberg Created on: 2017-04-11 20:10:11
Subsystem: 16. [scrollbar] Assigned To: nobody
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2017-04-20 02:07:21
Resolution: Fixed Closed By: kevin_walzer
    Closed on: 2017-04-20 02:07:21
Description:

From Tk version 8.5.18 and 8.6.4 onwards, the Tk scrollbar in the Mac implementation has been changed to use HITheme. This introduced an offset between the scrollbar slider visual appearance and the area where the user can click the slider area.

When a scrollbar is used in a Tk application (e.g. in a listbox, but this applies to all other widgets as well) and the mouse is used to vertically scroll through the listbox using the slider of the scrollbar, you need to click and hold the slider on the lower end in order to be able to move it. You can also click and hold below the actual slider, in the open space of the trough, it still moves. However, when you click on the upper part of the slider, the behaviour is as if you had clicked into the trough above the slider. So, the position where the mouse click occurs is not in sync with where the slider actually is visible. There is no difference between using [scrollbar] and [ttk::scrollbar].

Simple script to reproduce:

toplevel .qq
listbox .qq.l  -yscrollcommand [list .qq.sy set]
grid .qq.l -row 0 -column 0 -sticky ewsn
.qq.l insert end 1021 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109 \
	1117 1123 1129 1151 1153 1163 1171 1181 1187 1193 1201 1213 1217 1223 1229 \
	1231 1237 1249 1259 1277 1279 1283 1289 1291 1297 1301 1303 1307 1319 1321 \
	1327 1361 1367 1373 1381 1399 1409 1423 1427 1429 1433 1439 1447 1451 1453 \
	1459 1471 1481 1483 1487 1489 1493 1499 1511 1523 1531 1543 1549 1553 1559 \
	1567 1571 1579 1583 1597 1601 1607 1609 1613 1619 1621 1627 1637 1657 1663 \
	1667 1669 1693 1697 1699 1709 1721 1723 1733 1741 1747 1753 1759 1777 1783 \
	1787 1789 1801 1811 1823 1831 1847 1861 1867 1871 1873 1877 1879 1889 1901 \
	1907 1913 1931 1933 1949 1951 1973 1979 1987 1993 1997 1999 2003 2011 2017 \
	2027 2029 2039 2053 2063 2069 2081 2083 2087 2089 2099 2111 2113 2129 2131
scrollbar .qq.sy -command [list .qq.l yview]
grid .qq.sy -column 1 -row 0 -sticky ns

User Comments: kevin_walzer added on 2017-04-20 02:07:21:
I've committed an update for the scroller that addresses this bug and also fixes another long-standing issue. 

1. I've re-worked the metrics of the scroller to align with the Unix scrollbar metrics (in fact they are taken directly from the Unix code). This yields a solid improvement in the scrolling performance: the scrollbar is now smoother when scrolling up with the top of the scroll button. Because the entire scrolling mechanism is driven by the Unix implementation at the script level, this change was necessary. The previous version used Cocoa metrics and in retrospect did not mesh well at all with the Unix scroll implementation. 

It is important to understand that because the code is now based on the Unix scroller, it will NOT behave 100% identically to the previous Cocoa (and Carbon) implementations: in particular, the scrollbar will "page up/down" (jump) if the user holds down the mouse button in the scroll trough. This update, though, substantially reduces the chance of this happening while the user is dragging the upper part of the scrollbar. 

2. This update correctly implements highlighting of the scrollbar when the scrollbar is being dragged or when the mouse pointer enters/leaves the scrollbar area. This is a substantial improvement in the native look and feel of the Tk scrollbar on macOS.

Thanks for the report.

bll added on 2017-04-11 21:31:03:
I can confirm this portion of the bug report on Mac OS X 10.12.4:
    "You can also click and hold below the actual slider, 
     in the open space of the trough, it still moves."
For testing purposes, you can use:
  ttk::scrollbar .qq.sy -command [list .qq.l yview] -style Vertical.TScrollbar
to get a non-mac scrollbar.
(checked with 8.4.19, 8.5.9 and 8.6.6)