[Libreoffice-commits] core.git: sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Mon Mar 10 09:14:42 PDT 2014


 sc/source/ui/app/inputwin.cxx |   70 ++++++++++++++++++++++++------------------
 1 file changed, 41 insertions(+), 29 deletions(-)

New commits:
commit ed6b8c9f8d1b932300ce16d6188d10036827f676
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Mar 10 12:08:45 2014 -0400

    Select the whole text when the named range box gets focus.
    
    Not doing this had been bugging me for a long time since I use
    Shift-Ctrl-F5 to define named ranges a lot.  Small usability improvement.
    
    Change-Id: Ib1a4e4e26e15667598a603443dde05e08fdbe3b7

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 7bda59d..544a7f1 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -2484,43 +2484,55 @@ void ScPosWnd::DoEnter()
 
 bool ScPosWnd::Notify( NotifyEvent& rNEvt )
 {
-    bool nHandled = false;
+    bool bHandled = true;
 
-    if ( rNEvt.GetType() == EVENT_KEYINPUT )
+    switch (rNEvt.GetType())
     {
-        const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
-
-        switch ( pKEvt->GetKeyCode().GetCode() )
+        case EVENT_KEYINPUT:
         {
-            case KEY_RETURN:
-                DoEnter();
-                nHandled = true;
-                break;
+            const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
 
-            case KEY_ESCAPE:
-                if (nTipVisible)
-                {
-                    // escape when the tip help is shown: only hide the tip
-                    HideTip();
-                }
-                else
-                {
-                    if (!bFormulaMode)
-                        SetText( aPosStr );
-                    ReleaseFocus_Impl();
-                }
-                nHandled = true;
-                break;
+            switch ( pKEvt->GetKeyCode().GetCode() )
+            {
+                case KEY_RETURN:
+                    DoEnter();
+                    break;
+
+                case KEY_ESCAPE:
+                    if (nTipVisible)
+                    {
+                        // escape when the tip help is shown: only hide the tip
+                        HideTip();
+                    }
+                    else
+                    {
+                        if (!bFormulaMode)
+                            SetText( aPosStr );
+                        ReleaseFocus_Impl();
+                    }
+                    break;
+            }
         }
+        break;
+        case EVENT_GETFOCUS:
+        {
+            // Select the whole text upon focus.
+            OUString aStr = GetText();
+            SetSelection(Selection(0, aStr.getLength()));
+        }
+        break;
+        case EVENT_LOSEFOCUS:
+            HideTip();
+            bHandled = false;
+        break;
+        default:
+            bHandled = false;
     }
 
-    if ( !nHandled )
-        nHandled = ComboBox::Notify( rNEvt );
-
-    if ( rNEvt.GetType() == EVENT_LOSEFOCUS )
-        HideTip();
+    if (!bHandled)
+        bHandled = ComboBox::Notify(rNEvt);
 
-    return nHandled;
+    return bHandled;
 }
 
 void ScPosWnd::ReleaseFocus_Impl()


More information about the Libreoffice-commits mailing list