public void onBrowserEvent(Context context, Element parent, String value, NativeEvent event, ValueUpdater<String> valueUpdater)
for example,
if I create an instance of HeaderCell() headerCell1, and then I create another instance headerCell2, click on these two instances will have the same response hard code in the class HeaderCell().
// do something if it's indeed the image that was clicked
what should I do if I want click on each instance of HeaderCell() will have its custom logic?
On Wed, Apr 25, 2012 at 4:10 PM, Interbooker App <interbookerapp@gmail.com> wrote:
I'm not really sure if this is the best implementation, but it works for me. -- First, add this to your constructor:
public HeaderCell() {
super("click", "keydown");
}
-- Then, override the onBrowserEvent:
@Override
public void onBrowserEvent(Context context, Element parent, String value, NativeEvent event, ValueUpdater<String> valueUpdater) {
// Let AbstractCell handle the keydown event.
super.onBrowserEvent(context, parent, value, event, valueUpdater);
// Handle the click event.
if ("click".equals(event.getType())) {
EventTarget eventTarget = event.getEventTarget();
// in here we check whether the cell that was being clicked is an image, not the entire cell
if(eventTarget.toString().contains("img src") && !eventTarget.toString().contains("<div class")){
// do something if it's indeed the image that was clicked
}
}
}
Cheers, Lin
On Fri, Apr 20, 2012 at 10:38 AM, tong123123 <tong123123@gmail.com> wrote:
I found the answer finally, I wrongly import the
com.google.gwt.user.client.Element;
instead of
com.google.gwt.dom.client.Element;
On Friday, April 20, 2012 4:14:44 PM UTC+8, tong123123 wrote:I got some insight but still not clear, it show that--public void onBrowserEvent(Context context, Element parent, String value,
NativeEvent event, ValueUpdater<String> valueUpdater)
in ClickableImageCell2 is not overridepublic void onBrowserEvent(Context context, Element parent, C value,in AbstractCell,
NativeEvent event, ValueUpdater<C> valueUpdater)
but why in the api,
http://google-web-toolkit.googlecode.com/svn/javadoc/2.4/com/google/gwt/cell/client/AbstractCell.html#onBrowserEvent%28com.google.gwt.cell.client.Cell.Context,%20com.google.gwt.dom.client.Element,%20C,%20com.google.gwt.dom.client.NativeEvent,%20com.google.gwt.cell.client.ValueUpdater%29
Class ContactCell,@Override public void onBrowserEvent(Context context, Element parent, Contact value, NativeEvent event, ValueUpdater<Contact> valueUpdater)
is override of AbstractCell?
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/nImJY4gKNjcJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment