Adding my own pseudo classes to e4 CSS support? [message #1426928] |
Fri, 19 September 2014 12:43 |
Marina Knieling Messages: 83 Registered: February 2013 |
Member |
|
|
Hi guys,
I'm implementing my own CSS element providers and property handlers to
add support for other (own) widgets and some special properties.
I'd like to add a hover pseudo class for one of my own widgets. I tried
to simply check for "hover" in the pseudo parameter in the applyCSS*
method of the PropertyHandler but this doesn't seem to work. Is this
possible at all and if yes how would I achieve it?
This is my code so far (the property handler):
public boolean applyCSSProperty (Object element, String property,
CSSValue value, String pseudo, CSSEngine engine) throws Exception {
Widget widget = (Widget) ((WidgetElement) element).getNativeWidget();
if ("background-color".equals(property)) {
if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
Color newColor = (Color) engine.convert(value, Color.class,
widget.getDisplay());
if (widget instanceof MyMenuItem) {
MyMenuItem menuItem = (MyMenuItem) widget;
if ("hover".equals(pseudo)) {
System.out.println("hover background");
menuItem.setHoverBackgroundColor(newColor);
// TODO redraw necessary?
}
else {
menuItem.setBackgroundColor(newColor);
}
}
}
}
return false;
}
And the CSS:
MyMenuItem {
color: white;
background-color: red;
}
MyMenuItem:hover {
color: red;
background-color: white;
}
The normal (= not hovering) colors are set, but the hover colors aren't.
Thanks in advance for any hints or help
Marina Knieling
|
|
|
Powered by
FUDForum. Page generated in 0.03459 seconds