Reputation: 1556
I need to enable the "Save" button when user COPY - PATE something using Mouse clicks inside FormTextArea in GWT. I already tried with KeyUpHandler, ValueChangeHandler, ChangeHandler but didn't work as expected.
I already gone through Paste event on GWT
Upvotes: 0
Views: 298
Reputation: 1062
to catch an paste event from keyboard ctrl+v or from the contextmenu you have to override the onBrowserEvent
Method in your widget and catch the Event.ONPASTE
.
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
switch (event.getTypeInt()) {
case Event.ONPASTE:
//do stuff
break;
default:
break;
}
}
Upvotes: 3
Reputation: 554
I suppose you want enable the Save button when your textarea
is NOT empty.
You can use the KeyDownHandler
textArea.addKeyDownHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
if(textArea.getValue().isEmpty){
//disable
} else {
//enable
}
}
});
Sure, you will not be notified if user paste text via ContexMenu
but you cannot do anything for that.
You can use the ValueChangeHandler<String>
too but it will be fired only when your textarea
will lost the focus.
Hope it helps ...
Upvotes: 0