[haiku-commits] r34847 - haiku/trunk/src/apps/icon-o-matic/generic/gui

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 2 Jan 2010 00:57:27 +0100 (CET)

Author: stippi
Date: 2010-01-02 00:57:27 +0100 (Sat, 02 Jan 2010)
New Revision: 34847
Changeset: http://dev.haiku-os.org/changeset/34847/haiku
Ticket: http://dev.haiku-os.org/ticket/2749

Modified:
   haiku/trunk/src/apps/icon-o-matic/generic/gui/InputTextView.cpp
   haiku/trunk/src/apps/icon-o-matic/generic/gui/InputTextView.h
Log:
Always apply the changes to a property in the text editor when changing focus.
Fixes #2749.


Modified: haiku/trunk/src/apps/icon-o-matic/generic/gui/InputTextView.cpp
===================================================================
--- haiku/trunk/src/apps/icon-o-matic/generic/gui/InputTextView.cpp     
2010-01-01 23:25:47 UTC (rev 34846)
+++ haiku/trunk/src/apps/icon-o-matic/generic/gui/InputTextView.cpp     
2010-01-01 23:57:27 UTC (rev 34847)
@@ -1,9 +1,6 @@
 /*
- * Copyright 2006, Haiku.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
+ * Copyright 2006-2009, Stephan Aßmus <superstippi@xxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
  */
 
 #include "InputTextView.h"
@@ -69,10 +66,6 @@
                                // revert any typing changes
                                RevertChanges();
                                break;
-                       case B_TAB:
-                               // skip BTextView implementation
-                               BView::KeyDown(bytes, numBytes);
-                               // fall through
                        case B_RETURN:
                                ApplyChanges();
                                break;
@@ -89,12 +82,21 @@
 void
 InputTextView::MakeFocus(bool focus)
 {
-       if (focus != IsFocus()) {
-               if (BView* view = Parent())
-                       view->Invalidate();
-               BTextView::MakeFocus(focus);
-               if (focus)
-                       SelectAll();
+       if (focus == IsFocus())
+               return;
+
+       if (BView* view = Parent())
+               view->Invalidate();
+       BTextView::MakeFocus(focus);
+       if (focus) {
+               SelectAll();
+               fTextBeforeFocus = Text();
+       } else {
+               // Only pressing ESC is supposed to revert to the previous
+               // value and not invoke, but in that case, the text will already
+               // be the previous value when we lose focus here.
+               if (fTextBeforeFocus != Text())
+                       Invoke();
        }
 }
 

Modified: haiku/trunk/src/apps/icon-o-matic/generic/gui/InputTextView.h
===================================================================
--- haiku/trunk/src/apps/icon-o-matic/generic/gui/InputTextView.h       
2010-01-01 23:25:47 UTC (rev 34846)
+++ haiku/trunk/src/apps/icon-o-matic/generic/gui/InputTextView.h       
2010-01-01 23:57:27 UTC (rev 34847)
@@ -1,15 +1,12 @@
 /*
- * Copyright 2006, Haiku.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
+ * Copyright 2006-2009, Stephan Aßmus <superstippi@xxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
  */
-
 #ifndef INPUT_TEXT_VIEW_H
 #define INPUT_TEXT_VIEW_H
 
 #include <Invoker.h>
+#include <String.h>
 #include <TextView.h>
 
 class InputTextView : public BTextView,
@@ -50,6 +47,8 @@
                        void                            _CheckTextRect();
 
                        bool                            fWasFocus;
+                       BString                         fTextBeforeFocus;
+
 };
 
 #endif // INPUT_TEXT_VIEW_H


Other related posts:

  • » [haiku-commits] r34847 - haiku/trunk/src/apps/icon-o-matic/generic/gui - superstippi