Theme-ing CPTextfield

39 views
Skip to first unread message

Simon

unread,
Aug 11, 2016, 1:45:21 AM8/11/16
to Cappuccino & Objective-J
Hi all,

So, where's the best place to start looking for how to theme things ? 

The specific thing I'm trying to do is have a text-field with a light-coloured placeholder text, but when I do that, the cursor colour changes to the same colour as my placeholder (so it's basically invisible). The code looks like:


_pass = [[CPSecureTextField alloc] initWithFrame:rect];
[_pass setStringValue:@""];
[_pass setFont:[CPFont boldSystemFontOfSize:24.0]];
[_pass setTextColor:[CPColor blackColor]];
[_pass setEditable:YES];
[_pass setPlaceholderString:@"(password)"];
[[_pass setValue:[CPColor colorWithHexString:@"e0e0e0"] forThemeAttribute:"text-color" inState:CPTextFieldStatePlaceholder];

Presumably there's a way to get just the placeholder text coloured to be close-to-white, and keep the blinking cursor black, so it's actually visible without eye-strain :)

Cheers
   Simon

Alexander Ljungberg

unread,
Aug 15, 2016, 4:51:21 AM8/15/16
to objec...@googlegroups.com

Hi Simon,

Browsers set the colour of the caret to match the colour of the text and there’s no standard browser way to circumvent that.

The text field class could be rewritten to display the placeholder text using a div floating above the input which would allow its colour to be set without affecting the caret colour. Feel free to post that as a feature request, although I can’t say this has been a frequent request so it might not get much priority.

Maybe you could implement the same as a subclass of CPTextField.

In terms of where to start looking for how to theme things, just open up the ThemeDescriptor.j of one of the default themes:

https://github.com/cappuccino/cappuccino/blob/master/AppKit/Themes/Aristo2/ThemeDescriptors.j

Hope that helps.




Alexander
--
You received this message because you are subscribed to the Google Groups "Cappuccino & Objective-J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectivej+...@googlegroups.com.
To post to this group, send email to objec...@googlegroups.com.
Visit this group at https://groups.google.com/group/objectivej.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages