On 4 nov, 06:20, Dapeng <[email protected]> wrote:
> I notice 2.0M2 deprecates addClickHandler() in HyperLink and suggest
> user Anchor instead. But I can't see any benefits that we have two
> totally separated widgets for same <a> tag.   HyperLink has its
> advantage, ie, mouse-right-click open window. However, sometimes,
> Hyperlink also needs handle some mouse events.
>
> For example, in my scenario, there is a hyperlink in a popup panel. I
> want to hide this pop then load another history token, I use this
> code:
>
> Hyperlink tagCloud = new Hyperlink("view tag cloud", "tagcloudToken");
>                         tagCloud.addClickHandler(new ClickHandler(){
>                                 public void onClick(ClickEvent event) {
>                                         TagPopup.this.hide();
>                                 }
>                         });
>
> In 2.0M2,  whatever Hyperlink or Anchor, it can't fit the use. If I
> use Hyperlink, I have to use a deprecated addClickHandler(). If use
> Anchor, it  becomes impossible to open window in mouse-right-click.
>
> Any comments?

Right, HyperlinkImpl should be made somehow public so it would be safe
to use it with Anchor (safe meaning here forwards-compatible; it could
be a public static method of Anchor for instance, hiding the use of
HyperlinkImpl). (may I suggest you file an issue ;-) )

   Anchor tagCloud = ...;
   tagCloud.addClickHandler(new ClickHandler() {
      HyperlinkImpl impl = GWT.create(HyperlinkImpl.class);
      public void onClick(ClickEvent event) {
         if (impl.handleAsClick(event.getNativeEvent().cast())) {
            TagPopup.this.hide();
            History.newItem("tagcloudToken");
         }
      }
   });

The above works right now, and with a public static method, it would
turn into:
...
   if (Anchor.handleAsClick(event)) {
...
which is much more readable ;-)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to