Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to style Anchor in GWT?

Tags:

css

anchor

gwt

How can I add style for Anchor in GWT using UIBinder? I have following piece of code in UiBinder template XML:

<g:Anchor ui:field="forgotPassLink">Forgot password?</g:Anchor>

I know that .gwt-Anchor { } is used for styling this widget, but still no idea how to style hover effects. In normal CSS it would go like this:

a:link {color:#FF0000;}      /* unvisited link */
a:visited {color:#00FF00;}  /* visited link */
a:hover {color:#FF00FF;}  /* mouse over link */
a:active {color:#0000FF;}  /* selected link */

Do I have to handle this with BlurEvent and FocusEvent handlers on Anchor? If so ...that is boilerplate code..

like image 413
azec-pdx Avatar asked Feb 16 '11 16:02

azec-pdx


2 Answers

Use the same CSS pseudo-classes with the gwt-Anchor class:

.gwt-Anchor:link {color:#FF0000;}
.gwt-Anchor:visited {color:#00FF00;}
.gwt-Anchor:hover {color:#FF00FF;}
.gwt-Anchor:active {color:#0000FF;}

You can also use a.gwt-Anchor but it isn't strictly necessary.

like image 172
Jason Terk Avatar answered Nov 14 '22 23:11

Jason Terk


If you are using uibinder with the gwt HyperLink, it can be done like this:

<ui:style>
.mystyle a:link {
color:#3F3F3F; 
text-decoration:none;
}   
</ui:style>

<g:FlowPanel>
    <g:Hyperlink styleName='{style.mystyle}'/>
</g:FlowPanel>
like image 24
Steve QL Avatar answered Nov 14 '22 23:11

Steve QL