fix a small glitch in textfield cells and remove cheese from pro
authorkoda
Sat, 18 Sep 2010 19:02:55 +0200
changeset 3878 348f4104461d
parent 3877 bd1662bc6ed1
child 3879 a566d33b2856
child 3880 24810907e853
fix a small glitch in textfield cells and remove cheese from pro
project_files/HedgewarsMobile/Classes/CommodityFunctions.m
project_files/HedgewarsMobile/Classes/EditableCellView.m
--- a/project_files/HedgewarsMobile/Classes/CommodityFunctions.m	Sat Sep 18 19:02:09 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/CommodityFunctions.m	Sat Sep 18 19:02:55 2010 +0200
@@ -90,7 +90,7 @@
         case 2: //pro mode
             theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys:
                          [NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version",
-                         @"909000900000000000000900000000000000000000090000",@"ammostore_initialqt",
+                         @"909000900000000000000900000000000000000000000000",@"ammostore_initialqt",
                          @"000000000000000000000000000000000000000000000000",@"ammostore_probability",
                          @"000000000000020550000004000700400000000020000000",@"ammostore_delay",
                          @"111111111111111111111111111111111111111110010111",@"ammostore_crate", nil];
--- a/project_files/HedgewarsMobile/Classes/EditableCellView.m	Sat Sep 18 19:02:09 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/EditableCellView.m	Sat Sep 18 19:02:55 2010 +0200
@@ -138,9 +138,13 @@
 }
 
 // the textfield has been modified, tell the delegate to do something
--(void) textFieldDidEndEditing:(UITextField *)aTextField{
+-(void) textFieldDidEndEditing:(UITextField *)aTextField {
+    // this forces a save when user selects a new field
+    if ([self.textField.text isEqualToString:self.oldValue] == NO)
+        [self save:aTextField];
+
+    // restores default behaviour on caller
     ((UITableView*)[self superview]).scrollEnabled = YES;
-
     [(UITableViewController *)delegate navigationItem].rightBarButtonItem = [(UITableViewController *)delegate navigationItem].backBarButtonItem;
     [(UITableViewController *)delegate navigationItem].leftBarButtonItem = nil;
 }
@@ -154,17 +158,18 @@
 
 // the user pressed cancel so hide keyboard
 -(void) cancel:(id) sender {
+    // reverts any changes and performs a fake save for removing the keyboard
     self.textField.text = self.oldValue;
     [self save:sender];
 }
 
-// send the value to the delegate
+// send the value to the delegate (called before textFieldDidEndEditing)
 -(void) save:(id) sender {
-    if (delegate == nil || ![delegate respondsToSelector:@selector(saveTextFieldValue:withTag:)])
+    if (delegate == nil || [delegate respondsToSelector:@selector(saveTextFieldValue:withTag:)] == NO)
         return;
 
     // don't save if the textfield is invalid
-    if (![self textFieldShouldReturn:textField])
+    if ([self textFieldShouldReturn:textField] == NO)
         return;
 
     [delegate saveTextFieldValue:self.textField.text withTag:self.tag];