Revision: 27986 http://sourceforge.net/p/bibdesk/svn/27986 Author: hofman Date: 2022-10-03 14:16:52 +0000 (Mon, 03 Oct 2022) Log Message: ----------- keep only alternate cell
Modified Paths: -------------- trunk/bibdesk/BDSKSecureTextField.h trunk/bibdesk/BDSKSecureTextField.m Modified: trunk/bibdesk/BDSKSecureTextField.h =================================================================== --- trunk/bibdesk/BDSKSecureTextField.h 2022-10-03 09:41:26 UTC (rev 27985) +++ trunk/bibdesk/BDSKSecureTextField.h 2022-10-03 14:16:52 UTC (rev 27986) @@ -42,8 +42,7 @@ @interface BDSKSecureTextField : NSSecureTextField { BOOL showsText; NSButton *button; - NSTextFieldCell *secureCell; - NSTextFieldCell *unsecureCell; + NSTextFieldCell *alternateCell; } @property (nonatomic) BOOL showsText; Modified: trunk/bibdesk/BDSKSecureTextField.m =================================================================== --- trunk/bibdesk/BDSKSecureTextField.m 2022-10-03 09:41:26 UTC (rev 27985) +++ trunk/bibdesk/BDSKSecureTextField.m 2022-10-03 14:16:52 UTC (rev 27986) @@ -137,8 +137,7 @@ - (void)dealloc { BDSKDESTROY(button); - BDSKDESTROY(secureCell); - BDSKDESTROY(unsecureCell); + BDSKDESTROY(alternateCell); [super dealloc]; } @@ -152,52 +151,29 @@ return; showsText = flag; - NSTextFieldCell *oldCell = [self cell]; - NSTextFieldCell *newCell; + NSTextFieldCell *oldCell = [[self cell] retain]; - if (showsText) { - if (unsecureCell == nil) { - unsecureCell = [[BDSKUnsecureTextFieldCell alloc] initTextCell:@""]; - [unsecureCell setFont:[oldCell font]]; - [unsecureCell setControlSize:[oldCell controlSize]]; - [unsecureCell setControlTint:[oldCell controlTint]]; - [unsecureCell setEnabled:[oldCell isEnabled]]; - [unsecureCell setAlignment:[oldCell alignment]]; - [unsecureCell setWraps:[oldCell wraps]]; - [unsecureCell setScrollable:[oldCell isScrollable]]; - [unsecureCell setSelectable:[oldCell isSelectable]]; - [unsecureCell setEditable:[oldCell isEditable]]; - [unsecureCell setDrawsBackground:[oldCell drawsBackground]]; - [unsecureCell setBezeled:[oldCell isBezeled]]; - if ([oldCell isBezeled]) - [unsecureCell setBezelStyle:[oldCell bezelStyle]]; - secureCell = [oldCell retain]; - } - newCell = unsecureCell; - } else { - if (secureCell == nil) { - secureCell = [[BDSKUnsecureTextFieldCell alloc] initTextCell:@""]; - [secureCell setFont:[oldCell font]]; - [secureCell setControlSize:[oldCell controlSize]]; - [secureCell setControlTint:[oldCell controlTint]]; - [secureCell setEnabled:[oldCell isEnabled]]; - [secureCell setAlignment:[oldCell alignment]]; - [secureCell setWraps:[oldCell wraps]]; - [secureCell setScrollable:[oldCell isScrollable]]; - [secureCell setSelectable:[oldCell isSelectable]]; - [secureCell setEditable:[oldCell isEditable]]; - [secureCell setDrawsBackground:[oldCell drawsBackground]]; - [secureCell setBezeled:[oldCell isBezeled]]; - if ([oldCell isBezeled]) - [secureCell setBezelStyle:[oldCell bezelStyle]]; - unsecureCell = [oldCell retain]; - } - newCell = secureCell; + if (alternateCell == nil) { + alternateCell = [(showsText ? [BDSKUnsecureTextFieldCell alloc] : [BDSKSecureTextFieldCell alloc]) initTextCell:@""]; + [alternateCell setFont:[oldCell font]]; + [alternateCell setControlSize:[oldCell controlSize]]; + [alternateCell setControlTint:[oldCell controlTint]]; + [alternateCell setEnabled:[oldCell isEnabled]]; + [alternateCell setAlignment:[oldCell alignment]]; + [alternateCell setWraps:[oldCell wraps]]; + [alternateCell setScrollable:[oldCell isScrollable]]; + [alternateCell setSelectable:[oldCell isSelectable]]; + [alternateCell setEditable:[oldCell isEditable]]; + [alternateCell setDrawsBackground:[oldCell drawsBackground]]; + [alternateCell setBordered:[oldCell isBordered]]; + [alternateCell setBezeled:[oldCell isBezeled]]; + if ([oldCell isBezeled]) + [alternateCell setBezelStyle:[oldCell bezelStyle]]; } - [newCell setEnabled:[oldCell isEnabled]]; - [newCell setEditable:[oldCell isEditable]]; - [newCell setStringValue:[oldCell stringValue] ?: @""]; + [alternateCell setEnabled:[oldCell isEnabled]]; + [alternateCell setEditable:[oldCell isEditable]]; + [alternateCell setStringValue:[oldCell stringValue] ?: @""]; NSRange selectedRange = NSMakeRange(NSNotFound, 0); if ([self currentEditor]) { @@ -205,8 +181,11 @@ [[self window] makeFirstResponder:[self window]]; } - [self setCell:newCell]; + [self setCell:alternateCell]; + [alternateCell release]; + alternateCell = oldCell; + if (selectedRange.location != NSNotFound) { [[self window] makeFirstResponder:self]; [[self currentEditor] setSelectedRange:selectedRange]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit