cappuccino / cappuccino

Web Application Framework in JavaScript and Objective-J
https://cappuccino.dev/
GNU Lesser General Public License v2.1
2.21k stars 333 forks source link

CPTextField doesn't accept -setTextColor unless it already has string content #2985

Closed ThrudTheBarbarian closed 2 years ago

ThrudTheBarbarian commented 2 years ago

This will work: `

    _date   = [[CPTextField alloc] initWithFrame:CGRectMake(w-70,0,50,14)];

    [_date setStringValue:"--/--/--"];

    [_date setTextColor:[CPColor colorWithHexString:"888888"]];

    [self addSubview:_date];

`

... but remove the dummy -setStringValue: and the text is always black.

cappbot commented 2 years ago

Milestone: Someday. Label: #new. What's next? A reviewer should examine this issue.

daboe01 commented 2 years ago

@ThrudTheBarbarian swapping the lines setTextColor and setStringValue still gives me a gray textfield. can you please post the full reduction?

daboe01 commented 2 years ago

-#new +#needs-reduction

cappbot commented 2 years ago

Milestone: Someday. Label: #needs-reduction. What's next? A minimal test app should be created which demonstrates the concern of this issue in isolation.

ThrudTheBarbarian commented 2 years ago

Hmm - I'll try and create a reduction. I can't show the original I'm afraid.

ThrudTheBarbarian commented 2 years ago

AppController.txt

Ok, uploaded AppController.txt (which is really AppController.j but GitHub doesn't like .j). It creates a CPTextfield, sets the target/action to a method, and tries to change the colour of the textfield within that method. It then reads it back to see if it worked.

Here's the output of the CPLogs after typing something and pressing return:

[Info] 2021-07-21 17:10:35.796 Cappuccino [info]: Setting view <CPTextField 0x009b3b> to <CPColor 0x00a3f1> rgb(255, 0, 0) (Objective-J.js, line 576)
[Info] 2021-07-21 17:10:35.796 Cappuccino [info]: view <CPTextField 0x009b3b> text color now:<CPColor 0x007b0d> rgb(0, 0, 0) (Objective-J.js, line 576)

Visually there's no change to red (the "desired" colour)

If I then also add in 2 lines to set the initial content and the colour just after [tv setEditable:YES], thus:

    [tv setEditable:YES];
    [tv setStringValue:"xxx"];
    [tv setTextColor:[CPColor blueColor]];

... then I still don't see blue text (it's still black), but if I force a focus-removal by clicking outside of the browser window, then the text colour turns blue. That doesn't happen if I click inside the window.

didierkorthoudt commented 2 years ago

@ThrudTheBarbarian Strange. I've tested here, on current master, and everything is OK. Are you working with current master ?

didierkorthoudt commented 2 years ago

@daboe01 Did you observed the problem ?

ThrudTheBarbarian commented 2 years ago

I'm looking at ~/src/Cappuccino and the file dates are 4th July. I'm fairly sure that's the version of Cappuccino I'm using, and I checked out master.

I have a clean machine I've just set up, which I have to burn in this weekend. I'll set up a fresh Cappuccino install on that to make sure. This is all on Safari btw.

daboe01 commented 2 years ago

@didierkorthoudt i just had a look at the reduction of @ThrudTheBarbarian the call to setTextColor: does indeed not turn the text red as expected. however, the text turns red immediately after typing the string thereafter. this looks like a redraw issue to me.

daboe01 commented 2 years ago

-#needs-reduction

daboe01 commented 2 years ago

+AppKit

cappbot commented 2 years ago

Milestone: Someday. Label: AppKit. What's next? A reviewer should examine this issue.

didierkorthoudt commented 2 years ago

@ThrudTheBarbarian @daboe01 I've pushed #2993 that fixes this. Is this OK for you ?

daboe01 commented 2 years ago

@didierkorthoudt your PR is fine. however, when we are within editing, you additionally need to call [self _setCSSStyleForInputElement] to make the color change visible; i have placed a review comment in #2993.

ThrudTheBarbarian commented 2 years ago

@didierkorthoudt - Sorry for the tardiness on my part here. That demo I mentioned ? It went perhaps too well... I have had a string of them since and I'm giving another today to the VP and SVP.

I haven't wanted to upset my dev system (since I just have a portable at home these days) while they were ongoing. Hopefully this will be the last and I'll try and pull down and test :)

I really do appreciate that you've fixed it for me - thank you :)