From c02b45604808b6ffb6c41e671f4a0595ad13741c Mon Sep 17 00:00:00 2001 From: Bibiko Date: Mon, 10 Aug 2009 19:40:17 +0000 Subject: =?UTF-8?q?=E2=80=A2=20added=20to=20Custom=20Query=20table=20editi?= =?UTF-8?q?ng=20max=20text=20length=20validation=20=E2=80=A2=20SPFieldEdit?= =?UTF-8?q?orController:=20-=20improved=20textViewDidChangeSelection:=20to?= =?UTF-8?q?=20eg=20saves=20to=20correct=20rendered=20glyph=20after=20inser?= =?UTF-8?q?ting=20a=20non-base=20char=20+=20base=20char=20if=20this=20comb?= =?UTF-8?q?ination=20was=20typed=20as=20last=20glyph=20before=20pressing?= =?UTF-8?q?=20the=20OK=20button=20(otherwise=20foo=C2=A8=20will=20be=20sav?= =?UTF-8?q?ed=20instead=20of=20foo=C3=BC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/CustomQuery.m | 5 +++++ Source/SPFieldEditorController.h | 1 + Source/SPFieldEditorController.m | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index 7153e916..10b93a31 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -1723,6 +1723,11 @@ SPFieldEditorController *fieldEditor = [[SPFieldEditorController alloc] init]; + // Set max text length + if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"string"] + && [columnDefinition valueForKey:@"char_length"]) + [fieldEditor setTextMaxLength:[[columnDefinition valueForKey:@"char_length"] intValue]]; + id editData = [[fieldEditor editWithObject:[[fullResult objectAtIndex:rowIndex] objectAtIndex:[[aTableColumn identifier] intValue]] fieldName:[columnDefinition objectForKey:@"name"] usingEncoding:[mySQLConnection encoding] diff --git a/Source/SPFieldEditorController.h b/Source/SPFieldEditorController.h index f7b669f4..4205140f 100644 --- a/Source/SPFieldEditorController.h +++ b/Source/SPFieldEditorController.h @@ -50,6 +50,7 @@ int counter; unsigned long long maxTextLength; + BOOL editTextViewWasChanged; NSUserDefaults *prefs; } diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m index 230a3861..e5fd0550 100644 --- a/Source/SPFieldEditorController.m +++ b/Source/SPFieldEditorController.m @@ -29,6 +29,7 @@ #import "SPDataAdditions.h" #import "QLPreviewPanel.h" #import "SPDataCellFormatter.h" +#import "RegexKitLite.h" @implementation SPFieldEditorController @@ -39,7 +40,10 @@ (void) [self window]; counter = 0; maxTextLength = 0; - + + // Used for max text length recognition if last typed char is a non-space char + editTextViewWasChanged = NO; + // Allow the user to enter cmd+return to close the edit sheet in addition to fn+return [editSheetOkButton setKeyEquivalentModifierMask:NSCommandKeyMask]; } @@ -613,6 +617,12 @@ int newLength; + // Auxilary to ensure that eg textViewDidChangeSelection: + // saves a non-space char + base char if that combination + // occurs at the end of a sequence of typing before saving + // (OK button). + editTextViewWasChanged = ([replacementString length] == 1); + // Pure attribute changes are ok. if (!replacementString) return YES; @@ -647,7 +657,7 @@ { // Do nothing if user really didn't changed text (e.g. for font size changing return) - if(editSheetWillBeInitialized || ([[[notification object] textStorage] changeInLength]==0)) + if(!editTextViewWasChanged && (editSheetWillBeInitialized || ([[[notification object] textStorage] changeInLength]==0))) return; // clear the image and hex (since i doubt someone can "type" a gif) -- cgit v1.2.3