Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 426596

Summary: [iOS]: Disabled buttons have wrong foreground color
Product: [RT] RAP Reporter: Elias Volanakis <elias>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ivan, jboehme, mknauer, rsternberg
Version: 2.2   
Target Milestone: 2.3 M3   
Hardware: PC   
OS: other   
Whiteboard:

Description Elias Volanakis CLA 2014-01-24 10:43:43 EST
Button test = new Button( parent, SWT.PUSH );
test.setText( "enabled" );
test.setForeground( test.getDisplay().getSystemColor( SWT.COLOR_RED ) );
Button test2 = new Button( parent, SWT.PUSH );
test2.setForeground( test2.getDisplay().getSystemColor( SWT.COLOR_RED ) );
test2.setText( "disabled" );
test2.setEnabled( false );

On iOS with Tabris:

Result: text in test2 is blue.
Expected: text in test2 is red.
Comment 1 Markus Knauer CLA 2014-01-24 12:16:20 EST
You are *not* talking about the RAP web client on iOS, are you? If this is a Tabris client bug you can use [1]. I'm closing this bug here because it seems to be unrelated to RAP.

[1] https://github.com/eclipsesource/tabris/issues
Comment 2 Jordi Boehme Lopez CLA 2014-01-27 10:03:01 EST
This is a RAP/Protocol issue.

If you set a Control to disabled it will return foreground=null to the Client.
This only works for the browser client as it uses theming to determine a fallback foreground color when the server returns null as foreground color.

But that does not work with all other clients out there. A foreground color must never be null - especially when it was set on the server side.

The browser specific logic should not be handled on the server - this browser specific behavior must move to the javascript implementation.
Comment 3 Ivan Furnadjiev CLA 2014-01-27 10:10:28 EST
The code in question is in Control#ControlAdapter#getUserForeground(), where the foreground color is reset to null if control is disabled.
Comment 4 Ralf Sternberg CLA 2014-02-03 06:31:30 EST
I agree that the enabled state should not affect the foreground value in the protocol. Graying out disabled widgets should be a responsibility of the theming. It may already be done by the theming, in this case we could simply remove the switch in getUserForeground().
Comment 5 Ivan Furnadjiev CLA 2014-02-03 06:49:40 EST
(In reply to comment #4)
> I agree that the enabled state should not affect the foreground value in the
> protocol. Graying out disabled widgets should be a responsibility of the
> theming. It may already be done by the theming, in this case we could simply
> remove the switch in getUserForeground().
As colors set by code override colors set by themeing we need a client-side (WebClient) fix before removing the switch in getUserForeground().
Comment 6 Ivan Furnadjiev CLA 2014-04-23 07:51:56 EDT
Just a note: On Windows SWT Button#setForeground does nothing for all type of buttons.
Comment 7 Ivan Furnadjiev CLA 2014-04-28 09:53:01 EDT
Fixed in master with change https://git.eclipse.org/r/25545.