草庐IT

delegating

全部标签

javascript - 如何在 QML 中访问 ListView 的 ListModel 的 ListElement 的映射委托(delegate)数据?

本质上,我有一个普通的ListView:Rectangle{id:mylistListModel{id:mylistModelListElement{text:"blah1"}ListElement{text:"blah2"}ListElement{text:"blah3"}}Component{id:mylistDelegateText{id:mylistDelegateTexttext:textpropertyboolmylistDelegateTextEnabled:false}}ListView{id:mylistViewmodel:mylistModeldelegate:my

javascript - 以编程方式触发的事件不适用于事件委托(delegate)

如果有人能帮我弄清楚为什么在MooTools中使用事件委托(delegate)(来自Element.Delegation类)时无法以编程方式触发事件,我将不胜感激。有父有一个change一些child的听众元素。当更改事件由用户操作触发时,父div上的处理程序被触发,但是当我以编程方式使用fireEvent触发它时在任何子输入上,什么都不会发生。基本设置是:html​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​js$("listener").addEvent("change:rela

javascript - Angular:委托(delegate)模式。在 ngFor 内部优化处理程序的方法

例如:我需要输出一个列表。每个项目都会有一个(点击)处理程序,其中包含项目对象(如参数)。这个列表会经常动态更新:我会在Scroll上加载新项目,或者通过搜索过滤列表。Angular为每个项目添加一个事件监听器!问题:列表中可以有很多项,所以会有很多eventListener一直连接和断开。有没有办法应用委托(delegate)模式让只有一个eventListener事件? 最佳答案 您可以使用trackBy来提高性能。app.component.html应用程序组件.tstrackByFn(index,item){returnin

javascript - 动态委托(delegate)继承

假设我有构造函数Foo、Bar和Qux。我如何创建一个带有委托(delegate)链(使用那些构造函数)的新对象,我会动态选择?例如,一个对象将具有委托(delegate)链Foo->Bar。另一个对象将具有链Foo->Qux。functionFoo(){this.foo=function(){console.log('foo');}}functionBar(){this.bar=function(){console.log('bar');}}functionQux(){this.qux=function(){console.log('qux');}}对象fooBar将能够调用foo(

javascript - 如何仅处理子元素的委托(delegate)事件?

当使用.on委托(delegate)事件时,我如何定位子元素:我试过:childSelector=>*>:nth-child(n)但是当我从>开始时没有选择任何东西。$(selector).on(event,childSelector,handler);有时我想针对直接child,有时我不想:(伪代码)varfunc=function(selector,subSelector){$(selector).on("click",subSelector,function(){alert("mysubSelectorisclicked");});}func("#wrapper","direct

javascript - 如何在 jquery 中使用单个取消委托(delegate)方法删除多个事件委托(delegate)

我能否使以下内容更简单(而不是使用两次“取消委托(delegate)”)?$("#div1").undelegate("div","mouseenter").undelegate("div","mouseleave");我不希望除mouseenter和mouseleave之外的事件处理程序受到干扰。 最佳答案 用空格分隔您的事件。$("#div1").undelegate("div","mouseentermouseleave");不过,您应该使用on和off。$("#div1").off("mouseentermouseleave

c# - 在C#中使用参数委托(delegate)给其他线程

如何在C#中将带参数的函数委托(delegate)给另一个线程?如果我自己尝试,我会得到这个错误:errorCS0149:Methodnameexpected这是我现在拥有的:delegatevoidBarUpdateDelegate();privatevoidUpdateBar(intValue,intMaximum,ProgressBarBar){if(Bar.InvokeRequired){BarUpdateDelegateDelegation=newBarUpdateDelegate(Value,Maximum,Bar);//errorCS0149:Methodnameexpe

windows - C++/CLI 中的错误,除非使用 Pthread 创建委托(delegate)实例,否则无法获取函数地址

我在VisualC++2008Professional上使用C++/CLI,因为我使用的是Windows窗体,这意味着我已经管理了代码并且我正在尝试调用静态函数LoginAccounts,但我得到一个错误可能是因为我我正在混合托管代码和非托管代码,但我不知道该怎么做。我正在使用适用于Windows的PThreadSystem::Voidtesting_Click(System::Object^sender,System::EventArgs^e){pthread_create(&t,NULL,&Contas::LoginAccounts,this);//Errorinthisline}

c++ - Qt 模型/ View 委托(delegate) : How to simply translate text data?

我使用QSqlTableModel作为数据源并使用QTableView来显示数据。我还使用QDataWidgetMapper以单独的形式编辑数据。我想要做的就是将日期/时间字符串从数据库中的一种格式(2011-07-09T18:21:49)转换为另一种格式以显示在表中(18:21)以及另一种格式编辑映射(09.07.201118:21:49)我认为ItemDelegate是正确的方式,但我不想更改绘画等......我该如何正确地做? 最佳答案 好的,我认为这可能是正确的方法(中间数据模型),但现在我使用了QItemDelegate。

c# - 在特定线程上调用委托(delegate) C#

有没有办法让委托(delegate)在特定线程上运行?假设我有:CustomDelegatedel=someObject.someFunction;ThreaddedicatedThread=ThreadList[x];我能否拥有一致的后台长时间运行线程并在需要时调用我自己的委托(delegate)?每次都必须是同一个线程。[编辑]我希望它在专用线程上的原因是时间是我打算在其上运行委托(delegate)并在y毫秒后挂起线程,并在我运行另一个线程时恢复线程委托(delegate)给它。我看这是不可能的。我将有一个委托(delegate)队列,让线程的主要功能从中读取并运行。为了用一个具