From 9e0a2c04a8885bf21ee46fa3fd5ef739f6c96e32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=CC=81clav=20Slavi=CC=81k?= Date: Sun, 7 Mar 2021 18:38:47 +0100 Subject: [PATCH] Don't truncate item text in wxCheckListBox on macOS wxListBox's width adjustment code appears to have been written before wxCheckListBox's existence, and still assumed there's only one column, at index 0, in some places. In wxCheckListBox, however, there are two columns, and column 0 is the non-resizable checkbox one. We need to use column 1 (aka the last column) for automatic width updates, because that's where the text is. --- src/osx/cocoa/listbox.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/osx/cocoa/listbox.mm b/src/osx/cocoa/listbox.mm index ea02dee856..f2e97a33da 100644 --- a/src/osx/cocoa/listbox.mm +++ b/src/osx/cocoa/listbox.mm @@ -473,7 +473,9 @@ wxListWidgetColumn* wxListWidgetCocoaImpl::InsertCheckColumn( unsigned pos , con void wxListWidgetCocoaImpl::AdaptColumnWidth ( int w ) { - NSTableColumn *col = [[m_tableView tableColumns] objectAtIndex:0]; + // Note that the table can have more than one column as it's also used by + // wxCheckListBox, but the column containing the text is always the last one. + NSTableColumn *col = [[m_tableView tableColumns] lastObject]; [col setWidth:w]; m_maxWidth = w; } @@ -488,7 +490,7 @@ void wxListWidgetCocoaImpl::ListInsert( unsigned int n ) if ( m_autoSize ) { - NSCell *cell = [m_tableView preparedCellAtColumn:0 row:n]; + NSCell *cell = [m_tableView preparedCellAtColumn:[m_tableView numberOfColumns]-1 row:n]; NSSize size = [cell cellSize]; int width = (int) ceil(size.width);