[PATCH libreoffice-4-0] Template Manager: select first item when getting focus if no...

Bosdonnat Cedric (via Code Review) gerrit at gerrit.libreoffice.org
Fri Mar 22 09:17:17 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2910

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/10/2910/1

Template Manager: select first item when getting focus if no selection

Change-Id: Ie012e010ca92728725535345c76fc9f5eb31a254
(cherry picked from commit ec2f84b376f595b0553297d25b7716f6b97e1b87)
---
M sfx2/source/control/thumbnailview.cxx
1 file changed, 18 insertions(+), 1 deletion(-)



diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index c996f0f..57dba07 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -579,12 +579,29 @@
 
 void ThumbnailView::GetFocus()
 {
-    Control::GetFocus();
+    // Select the first item if nothing selected
+    int nSelected = -1;
+    for (size_t i = 0, n = mItemList.size(); i < n && nSelected == -1; ++i)
+    {
+        if (mItemList[i]->isSelected())
+            nSelected = i;
+    }
+
+    if ( nSelected == -1 && mItemList.size( ) > 0 )
+    {
+        mItemList[0]->setSelection(true);
+        maItemStateHdl.Call(mItemList[0]);
+
+        if (IsReallyVisible() && IsUpdateMode())
+            Invalidate();
+    }
 
     // Tell the accessible object that we got the focus.
     ThumbnailViewAcc* pAcc = ThumbnailViewAcc::getImplementation( GetAccessible( sal_False ) );
     if( pAcc )
         pAcc->GetFocus();
+
+    Control::GetFocus();
 }
 
 void ThumbnailView::LoseFocus()

-- 
To view, visit https://gerrit.libreoffice.org/2910
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie012e010ca92728725535345c76fc9f5eb31a254
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Bosdonnat Cedric <cedric.bosdonnat at free.fr>



More information about the LibreOffice mailing list