Hello List,
I'm somewhat heading down a road of pain with this. Maybe I approach the
problem from the wrong angle, so I wanted to ask for advice.
My goal is to have a NSTextField that can be toggled to display a Password in
clear or bulleted format. Sort of NSTextField - NSSecureTextField
I'm using a custom NSTextFieldCell to get a different look of the cell and also
to add a toggle Button inside the Field.
The drawing of the actual control is easy. As I can use a NSSecureTextField
cell to draw hidden, and my normal cell to draw unhidden passwords.
The point where I'm struggling is the field editor.
My solutions (with none working fully)
#1 Use a NSSecureTextField and supply a standard NSTextView Field editor to
display plain text
That's not working, as NSSecureTextField demands a NSSecureTextField as it's
field editor. So the only way would be to subclass private API and buble all
calls up to NSTextView's implementation.
#2 Use a NSTextField and supply a custom FieldEditor that can draw bullets like
the NSSecureTextField can.
This leads to a custom NSLayoutManager and then the problems start.
I tried supplying my own implementation of
- (NSUInteger)getGlyphsInRange:(NSRange)glyphRange
glyphs:(NSGlyph *)glyphBuffer
characterIndexes:(NSUInteger *)charIndexBuffer
glyphInscriptions:(NSGlyphInscription *)inscribeBuffer
elasticBits:(BOOL *)elasticBuffer
bidiLevels:(unsigned char *)bidiLevelBuffer;
- (void)drawGlyphsForGlyphRange:(NSRange)glyphsToShow atPoint:(NSPoint)origin
but I'm having difficulties with custom fonts, like if someone uses emojis I'm
unable to get the correct character count, as emojis consist of 2bytes, not 1.
The string length gets reported with
2. And the drawing is done a bit lower than the normal bullets.
I'm beginning to think, that I'm at a very low level – even too low – and this
problem can be dealt with at much higher points, but thus far I've not found a
way to do it.
Maybe I should spent some weeks digging through al the text system
documentation :-(
#3 An NSTabView with the two input fields side by side and just toggle them
back and forth.
Might be the easy way out but it seemed so overblown to use so many views for
this "simple" problem. Maybe it's the simples solution altogether.
-Michael
___m i c h a e l s t a r k e____
geschäftsführer
HicknHack Software GmbH
www.hicknhack-software.com
___k o n t a k t____
+49 (170) 3686136
[email protected]
___H i c k n H a c k S o f t w a r e G m b H____
geschäftsführer - maik lathan | andreas reischuck | michael starke
bayreuther straße 32
01187 dresden
amtsgericht dresden HRB 30351
sitz - dresden
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]