转GWTEXT中增加tool的控制

转自这个文章
[url]http://code.google.com/p/gwt-ext/issues/detail?id=406[/url]

Added a new Interface that implementors should implement the onClick event. This
event does pass the necessary information to the Tool.

The new interface is ToolHandler and the signature of the onclick event is:
public void onClick(EventObject e, ExtElement toolEl, Panel panel);

With this, now the you can change the icon and toggle it as it is the case of
pin/unpin.

Here is an example of how to change the pin/unpin icon when using ToolHandler:


public class myToolHandler implements ToolHandler{
boolean pin = false;
ExtElement ele = null;

public void setElement(){
EventManager.addListener(ele.getDOM(), "mouseover", new EventCallback(){
public void execute(EventObject e) {
if(pin){
ele.removeClass("x-tool-unpin-over");
ele.addClassOnOver("x-tool-pin-over");
}else{
ele.removeClass("x-tool-pin-over");
ele.addClassOnOver("x-tool-unpin-over");
}
}
}, new ListenerConfig(){
{
setStopEvent(true);
}
});
}

public void onClick(EventObject e, ExtElement toolEl, Panel panel) {
if(pin){
Ext.fly(toolEl.getDOM()).replaceClass("x-tool x-tool-pin", "x-tool x-tool-
unpin");
}else{
Ext.fly(toolEl.getDOM()).replaceClass("x-tool x-tool-unpin", "x-tool x-tool-
pin");
}
pin = !pin;
if(ele == null){
ele = toolEl;
setElement();
}
}
}

The above works well... Except in IE when the icon is PIN and you hover on it, it
shows as UNPIN. Could not figure out why!


Comment 2 by menschfe...@gmail.com, Feb 02, 2009

"The above works well... Except in IE when the icon is PIN and you hover on it, it
shows as UNPIN. Could not figure out why!"

Anyone know the fix for this? I get the same result in Chrome.

Comment 3 by stylina...@gmail.com, Jun 29, 2010

FYI - I was able to fix the hover issue by changing:

EventManager.addListener(ele.getDOM(), "mouseover", new EventCallback()

to:

EventManager.addListener(ele.getDOM(), "mouseenter", new EventCallback()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值