[vlc-commits] [Git][videolan/vlc][master] 2 commits: macosx: Fix double-clicking on tracks in VLCLibraryAlbumTableCellView

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Aug 18 06:38:36 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
974b6d2f by Claudio Cambra at 2025-08-18T06:20:51+00:00
macosx: Fix double-clicking on tracks in VLCLibraryAlbumTableCellView

It seems NSTableViews need to be enclosed in an NSScrollView to correctly handle some mouse events

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
d7c39df9 by Claudio Cambra at 2025-08-18T06:20:51+00:00
macosx: Check that clickedRow is valid before accessing arrays with it in tracksTableViewDoubleClickAction

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


1 changed file:

- modules/gui/macosx/library/audio-library/VLCLibraryAlbumTableCellView.m


Changes:

=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAlbumTableCellView.m
=====================================
@@ -51,12 +51,26 @@ NSString * const VLCLibraryAlbumTableCellTableViewColumnIdentifier = @"VLCLibrar
 
 const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
 
+ at interface VLCNonScrollableScrollView : NSScrollView
+ at end
+
+ at implementation VLCNonScrollableScrollView
+
+- (void)scrollWheel:(NSEvent *)event
+{
+    // Pass the scroll event to the next responder instead of handling it
+    [self.nextResponder scrollWheel:event];
+}
+
+ at end
+
 @interface VLCLibraryAlbumTableCellView ()
 {
     VLCLibraryController *_libraryController;
     VLCLibraryItemInternalMediaItemsDataSource *_tracksDataSource;
     VLCLibraryAlbumTracksTableViewDelegate *_tracksTableViewDelegate;
     VLCLibraryTableView *_tracksTableView;
+    NSScrollView *_tracksScrollView;
     NSTableColumn *_column;
 }
 
@@ -175,9 +189,19 @@ const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
 
 - (void)setupTracksTableView
 {
+    // Create scroll view container that doesn't intercept scroll events
+    _tracksScrollView = [[VLCNonScrollableScrollView alloc] initWithFrame:NSZeroRect];
+    _tracksScrollView.borderType = NSNoBorder;
+    _tracksScrollView.hasVerticalScroller = NO;
+    _tracksScrollView.hasHorizontalScroller = NO;
+    _tracksScrollView.drawsBackground = NO;
+    _tracksScrollView.verticalScrollElasticity = NSScrollElasticityNone;
+    _tracksScrollView.horizontalScrollElasticity = NSScrollElasticityNone;
+    
     _tracksTableView = [[VLCLibraryTableView alloc] initWithFrame:NSZeroRect];
     _tracksTableView.identifier = VLCLibraryAlbumTableCellTableViewIdentifier;
     _tracksTableView.allowsMultipleSelection = YES;
+    _tracksTableView.headerView = nil;
     _column = [[NSTableColumn alloc] initWithIdentifier:VLCLibraryAlbumTableCellTableViewColumnIdentifier];
     _column.width = [self expectedTableViewWidth];
     _column.maxWidth = MAXFLOAT;
@@ -197,18 +221,19 @@ const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
     _tracksTableView.doubleAction = @selector(tracksTableViewDoubleClickAction:);
     _tracksTableView.target = self;
 
-    _tracksTableView.translatesAutoresizingMaskIntoConstraints = NO;
-    [self addSubview:_tracksTableView];
-    NSString *horizontalVisualConstraints = [NSString stringWithFormat:@"H:|-%f-[_representedImageView]-%f-[_tracksTableView]-%f-|",
+    _tracksScrollView.documentView = _tracksTableView;
+    _tracksScrollView.translatesAutoresizingMaskIntoConstraints = NO;
+    [self addSubview:_tracksScrollView];
+    NSString *horizontalVisualConstraints = [NSString stringWithFormat:@"H:|-%f-[_representedImageView]-%f-[_tracksScrollView]-%f-|",
                                              VLCLibraryUIUnits.largeSpacing,
                                              VLCLibraryUIUnits.largeSpacing,
                                              VLCLibraryUIUnits.largeSpacing];
-    NSString *verticalVisualContraints = [NSString stringWithFormat:@"V:|-%f-[_albumNameTextField]-%f-[_artistNameTextButton]-%f-[_tracksTableView]->=%f-|",
+    NSString *verticalVisualContraints = [NSString stringWithFormat:@"V:|-%f-[_albumNameTextField]-%f-[_artistNameTextButton]-%f-[_tracksScrollView]->=%f-|",
                                           VLCLibraryUIUnits.largeSpacing,
                                           VLCLibraryUIUnits.smallSpacing,
                                           VLCLibraryUIUnits.mediumSpacing,
                                           VLCLibraryUIUnits.largeSpacing];
-    NSDictionary *dict = NSDictionaryOfVariableBindings(_tracksTableView, _representedImageView, _albumNameTextField, _artistNameTextButton);
+    NSDictionary *dict = NSDictionaryOfVariableBindings(_tracksScrollView, _representedImageView, _albumNameTextField, _artistNameTextButton);
     [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:horizontalVisualConstraints options:0 metrics:0 views:dict]];
     [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:verticalVisualContraints options:0 metrics:0 views:dict]];
 
@@ -369,8 +394,8 @@ const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
     NSArray * const tracks = album.mediaItems;
     const NSUInteger trackCount = tracks.count;
     const NSInteger clickedRow = _tracksTableView.clickedRow;
-    if (clickedRow < trackCount) {
-        VLCMediaLibraryMediaItem * const mediaItem = tracks[_tracksTableView.clickedRow];
+    if (clickedRow >= 0 && clickedRow < trackCount) {
+        VLCMediaLibraryMediaItem * const mediaItem = tracks[clickedRow];
         VLCLibraryRepresentedItem * const representedItem = [[VLCLibraryRepresentedItem alloc] initWithItem:mediaItem parentType:VLCMediaLibraryParentGroupTypeAlbum];
 
         [representedItem play];



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5753828d2e8d4701c0ff0d9c68a67503739db572...d7c39df91e3c0bf9ab0bbfe0edaaca754c033a6f

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5753828d2e8d4701c0ff0d9c68a67503739db572...d7c39df91e3c0bf9ab0bbfe0edaaca754c033a6f
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list