View Issue Details

IDProjectCategoryView StatusLast Update
0031013PatchesWidgetsetpublic2017-04-07 23:59
ReporterStefan KopfAssigned ToJuha Manninen 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformCarbonOSOS-XOS Version
Product Version1.6Product Build 
Target VersionFixed in Version 
Summary0031013: [PATCH] Fix: Mac / Carbon: TListBox.SetItemIndex does not scroll item into view
DescriptionWhen setting TListBox.ItemIndex to a value outside the current view, then Win32 Widgetset scrolls the view to show the newly selected item.
The Carbon Widgetset does not. This patch fixes this problem.
Steps To ReproduceOn Mac/Carbon:
1. Add a TListBox to a TForm
2. Add more lines to the TListBox than can be displayed
3. Add a button to the TForm, which sets TListBox.ItemIndex to the last element
4. Run the application and press the button
Expected:
The last item is selected and the listbox has scrolled to show this element
However:
The last element is not visible.
TagsNo tags attached.
Fixed in Revisionr54566
LazTarget-
WidgetsetCarbon
Attached Files
  • Carbon_ListBox_SetItemIndex.patch (1,155 bytes)
    Index: lcl/interfaces/carbon/carbonlistviews.pp
    ===================================================================
    --- lcl/interfaces/carbon/carbonlistviews.pp	(revision 53072)
    +++ lcl/interfaces/carbon/carbonlistviews.pp	(working copy)
    @@ -1406,7 +1406,7 @@
     procedure TCarbonDataBrowser.ShowItem(AIndex: Integer; Partial: Boolean);
     begin
       // TODO: partial show
    -  OSError(RevealDataBrowserItem(Widget, AIndex, kDataBrowserNoItem,
    +  OSError(RevealDataBrowserItem(Widget, AIndex + 1, kDataBrowserNoItem,
         kDataBrowserRevealWithoutSelecting), Self, 'ShowItem', 'RevealDataBrowserItem');
     end;
     
    Index: lcl/interfaces/carbon/carbonwsstdctrls.pp
    ===================================================================
    --- lcl/interfaces/carbon/carbonwsstdctrls.pp	(revision 53072)
    +++ lcl/interfaces/carbon/carbonwsstdctrls.pp	(working copy)
    @@ -686,6 +686,7 @@
       if not CheckHandle(ACustomListBox, Self, 'SetItemIndex') then Exit;
     
       TCarbonListBox(ACustomListBox.Handle).SetItemIndex(AIndex);
    +  TCarbonListBox(ACustomListBox.Handle).ShowItem(AIndex, False);
     end;
     
     {------------------------------------------------------------------------------
    

Activities

Stefan Kopf

2016-11-26 16:52

reporter  

Carbon_ListBox_SetItemIndex.patch (1,155 bytes)
Index: lcl/interfaces/carbon/carbonlistviews.pp
===================================================================
--- lcl/interfaces/carbon/carbonlistviews.pp	(revision 53072)
+++ lcl/interfaces/carbon/carbonlistviews.pp	(working copy)
@@ -1406,7 +1406,7 @@
 procedure TCarbonDataBrowser.ShowItem(AIndex: Integer; Partial: Boolean);
 begin
   // TODO: partial show
-  OSError(RevealDataBrowserItem(Widget, AIndex, kDataBrowserNoItem,
+  OSError(RevealDataBrowserItem(Widget, AIndex + 1, kDataBrowserNoItem,
     kDataBrowserRevealWithoutSelecting), Self, 'ShowItem', 'RevealDataBrowserItem');
 end;
 
Index: lcl/interfaces/carbon/carbonwsstdctrls.pp
===================================================================
--- lcl/interfaces/carbon/carbonwsstdctrls.pp	(revision 53072)
+++ lcl/interfaces/carbon/carbonwsstdctrls.pp	(working copy)
@@ -686,6 +686,7 @@
   if not CheckHandle(ACustomListBox, Self, 'SetItemIndex') then Exit;
 
   TCarbonListBox(ACustomListBox.Handle).SetItemIndex(AIndex);
+  TCarbonListBox(ACustomListBox.Handle).ShowItem(AIndex, False);
 end;
 
 {------------------------------------------------------------------------------

Juha Manninen

2017-04-07 23:59

developer   ~0099483

Applied, thanks.

Issue History

Date Modified Username Field Change
2016-11-26 16:52 Stefan Kopf New Issue
2016-11-26 16:52 Stefan Kopf File Added: Carbon_ListBox_SetItemIndex.patch
2017-04-07 23:23 Juha Manninen Assigned To => Juha Manninen
2017-04-07 23:23 Juha Manninen Status new => assigned
2017-04-07 23:59 Juha Manninen Fixed in Revision => r54566
2017-04-07 23:59 Juha Manninen LazTarget => -
2017-04-07 23:59 Juha Manninen Note Added: 0099483
2017-04-07 23:59 Juha Manninen Status assigned => resolved
2017-04-07 23:59 Juha Manninen Resolution open => fixed