| Ignore CSS for some Widgets [message #889729] |
Tue, 19 June 2012 10:18  |
Quang Tran Messages: 9 Registered: June 2012 |
Junior Member |
|
|
Hi,
we have in our Application some Labels which shows depending on a state the text in green or red (background)
This doesn't harmonise with the CSS Binding in E4, because we set the background before the CSS Databinding is running.
So the text, at first creation, no matter in what state we are, is the default color defined in CSS.
I did a workaround by adding a paint listener to the label.
label.addListener( SWT.Paint, new Listener() {
@Override
public void handleEvent(final Event event) {
if( isActive ) {
label.setBackground( green );
} else {
label.setBackground( red );
}
}
} );
But I don't like this solution, is there any other way?
|
|
|
|
| Re: Ignore CSS for some Widgets [message #889906 is a reply to message #889729] |
Wed, 20 June 2012 04:14   |
Quang Tran Messages: 9 Registered: June 2012 |
Junior Member |
|
|
Here is another example why we need a function to ignore css for some widgets:
If you have a dark css theme and a part of your css file is defined as follows:
.MPartStack.active ExpandBar {
background-color: #101010;
color: black;
}
.MPartStack ExpandBar {
background-color: #101010;
color: black;
}
Label {
font: Verdana 8px;
color: white;
}
Composite Label {
color: white;
}
And you have a viewpart, which shows the text color of the labels, depending on a state, in red or green. This does not work if your view loose the focus and gain it again later, because the label colors will be white again due to the CSS binding.
Quang
[Updated on: Wed, 20 June 2012 04:15] Report message to a moderator
|
|
|
|
| Re: Ignore CSS for some Widgets [message #891505 is a reply to message #889729] |
Mon, 25 June 2012 02:14  |
Quang Tran Messages: 9 Registered: June 2012 |
Junior Member |
|
|
Hi Tom,
Quote:Why are you need creating a CSS-Rule for highlighted labels?
What do you mean by that?
Current-Code:
-------------
Label l = ...
l.setForegroundColor(....)
CSS/Java-Code:
---------
Css:
Label.highlight {
color: red;
}
Java:
IStylingEngine se = ...
Label l = ...
se.setClassname("highlighted");
this seems like a good solution for us, thanks!
|
|
|
Powered by
FUDForum. Page generated in 0.01607 seconds