Commits

Jay Yu  committed aaa8cbf

started to build Undo function

  • Participants
  • Parent commits e15f6ee

Comments (0)

Files changed (2)

File Calculator/CalculatorViewController.m

 
     if ([@"Test 3" isEqualToString:testNumber]) {
         self.testVariableValues = nil; 
-        self.variablesDisplay.text = @"Variable not set";
+        self.variablesDisplay.text = @"Variables not set";
         return;
     }
     
     self.variablesDisplay.text = [varList componentsJoinedByString:@", "];
 }
 
+- (IBAction)undoPressed
+{
+    if (self.userIsInTheMiddleOfEnteringANumber) {
+        [self backspacePressed];
+    }
+    if (! self.userIsInTheMiddleOfEnteringANumber) {
+        
+    }
+}
+
 - (void)viewDidUnload {
     self.history = nil;
     self.variablesDisplay = nil;

File Calculator/en.lproj/MainStoryboard.storyboard

                                 </connections>
                             </button>
                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="Svj-HG-KZk">
-                                <rect key="frame" x="236" y="184" width="64" height="40"/>
+                                <rect key="frame" x="236" y="185" width="64" height="40"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                 <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
                                 <state key="normal" title="/">
                                 </connections>
                             </button>
                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="c7h-b2-JmJ">
-                                <rect key="frame" x="20" y="378" width="64" height="40"/>
+                                <rect key="frame" x="20" y="377" width="64" height="24"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                 <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
                                 <state key="normal" title="+/-">
                                     <action selector="variablePressed:" destination="2" eventType="touchUpInside" id="9BW-ix-N33"/>
                                 </connections>
                             </button>
-                            <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="vars:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="Ftu-AO-3GO">
-                                <rect key="frame" x="20" y="425" width="280" height="15"/>
+                            <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Variables not set" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="Ftu-AO-3GO">
+                                <rect key="frame" x="20" y="409" width="208" height="24"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="12"/>
                                 <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
                                 <nil key="highlightedColor"/>
                             </label>
                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="DGX-6e-d6I">
-                                <rect key="frame" x="92" y="378" width="64" height="40"/>
+                                <rect key="frame" x="92" y="377" width="64" height="24"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                 <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
                                 <state key="normal" title="Test 1">
                                 </connections>
                             </button>
                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="lje-dH-XYs">
-                                <rect key="frame" x="162" y="378" width="68" height="40"/>
+                                <rect key="frame" x="164" y="377" width="64" height="24"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                 <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
                                 <state key="normal" title="Test 2">
                                 </connections>
                             </button>
                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="Zwc-1V-KUR">
-                                <rect key="frame" x="234" y="378" width="68" height="40"/>
+                                <rect key="frame" x="236" y="377" width="64" height="24"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                 <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
                                 <state key="normal" title="Test 3">
                                     <action selector="testPressed:" destination="2" eventType="touchUpInside" id="bEv-2L-4hg"/>
                                 </connections>
                             </button>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="cMm-E7-wqw">
+                                <rect key="frame" x="236" y="409" width="64" height="24"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                <fontDescription key="fontDescription" type="boldSystem" pointSize="11"/>
+                                <state key="normal" title="Undo">
+                                    <color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
+                                    <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
+                                </state>
+                                <state key="highlighted">
+                                    <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                </state>
+                                <connections>
+                                    <action selector="undoPressed:" destination="2" eventType="touchUpInside" id="WNX-hf-4ER"/>
+                                </connections>
+                            </button>
                         </subviews>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
                     </view>
                     </connections>
                 </viewController>
             </objects>
-            <point key="canvasLocation" x="175" y="72"/>
+            <point key="canvasLocation" x="561" y="72"/>
         </scene>
     </scenes>
     <classes>