I'd like to set a mouse listener to my Label so that I can change the cursor to a HAND_CURSOR when the user places their mouse over a label.
<g:Label text="Overview" styleName="left_menu_title" ui:field="lb_overview"/>
I tried to set style css "cursor: hand;" for this Label, but when run, all attribute cursor were replaced.
Do you have any suggestion?
The answer provided by user1557828 will in fact cause the Label to show the cursor when the mouse is over it, but there is a simpler way to achieve the same result:
Label testLabel = new Label("Text Goes Here);
testLabel.getElement().getStyle().setCursor(Cursor.POINTER);
This will set the cursor at instantiation and the style will persist. It is not necessary to re-apply the style each time the mouse moves over the label.
The proper way to do it would be:
.left_menu_title {
cursor: pointer;
}
and
<g:Label text="Overview" styleName="{style.left_menu_title}" ui:field="lb_overview"/>
where to this one..
Label testLabel = new Label("Text Goes Here);
testLabel.getElement().getStyle().setCursor(Cursor.POINTER);
in my code provided below..
{
xtype:'label',
text:'testLabel',
id:'cancel1',
Label testLabel = new Label("Text Goes Here);
testLabel.getElement().getStyle().setCursor(Cursor.POINTER);
listeners : {
render : function(d) {
d.getEl().on('click', function(){ this.fireEvent('click', d); }, d);
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With