您的位置:首页 >> Web开发 >> CGI技术 >> 正文
CGI技术 RSS
 

Perl/Tk FAQ - 10.6. 如何设置绑定

http://www.rdxx.com 06年08月12日 00:00 我要投稿

关键词: 设置 , 绑定 , FAQ , Perl

  原文:

10.6. How do I add bindings?

On Fri, 15 Sep 95 10:30:56 BST Nick Ing-Simmons <Nick.Ing-Simmons@tiuk.ti.com> writes: Re: Multiple binds to a single widget?**************************************On Thu, 14 Sep 1995 14:57:54 -0400Alain St <astdenis@cmc.doe.CA> writes:!In the tcl/tk doc I have, they say that prepending the script !with '+' appends the new binding to the current one.!!How do I do that in perlTk? !

You cannot do that that way (yet?) - one issue is what it would mean to prepend '+' to a perl/Tk callback :

$widget->bind('<A>','+',[\&subname,$arg]); # did not look right to me

Other issue is that I would need to manage a list-of-callbacks in glue code.

Bind your new command to a new tag:

$widget->bind('Extra',....);

And add Extra to the widgets bindtags:

$widget->bindtags([ref($widget),$widget,'Extra', $widget->toplevel,'all']);





译文:

10.6. 如何设置绑定?



(译者注:这好像是一个邮件回复,不过已经很老了……)

On Fri, 15 Sep 95 10:30:56 BST Nick Ing-Simmons写到:

回复:如何给一个组件设置多个绑定?

*********************************

On Thu, 14 Sep 1995 14:57:54 –0400

Alain St写到:

!在Tcl/Tk中,我知道只要在代码中使用’+’就可以增加新的绑定了。

!那么在Perl/Tk中应该怎么做?



你不能用这样的方法做——一种方法是在Perl/Tk的回应函数前面加上’+’:

$widget -> bind(‘<A>’,’+’,[\&subname,$arg]);

#但是这样不行。



另一种方法就是需要处理一个连串的会应函数的列表。

首先,将你的新功能绑定到一个新的标签上:

$widget -> bind(‘Extra’,…);

然后,把这个标签(Extra)添加到组件的“绑定标签”(bindtags)中:

$widget->bindtags([ref($widget),$widget,'Extra',$widget->toplevel,'all']);

(译者注:以我的理解,这中方法就是可以方便的实现给多个不同的组件设置同一种绑定,或给一个组件设置多个不同的绑定。建议有兴趣的朋友参阅一下手册perldoc Tk::bindtags)

 
 
标签: 设置 , 绑定 , FAQ , Perl 打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站