我发现当Hello使用鼠标粘贴文本(即)时,以下函数将抛出一个空的弹出窗口:
$('input:text').onpaste = function()
{
alert($('input:text').val());
});
Run Code Online (Sandbox Code Playgroud)
问题是,当onpaste事件被触发时,文本实际上还没有粘贴到输入字段(至少这是我的猜测).所以将功能更改为:
$('input:text').onpaste = function()
{
setTimeout(function()
{
alert($('input:text').val()
}, 100);
}
Run Code Online (Sandbox Code Playgroud)
通过Hello在粘贴到输入字段时显示带有文本的弹出窗口来提供正确的结果.
现在我的问题是:是否有可能在不使用该setTimeout()功能的情况下捕获粘贴的文本?这种解决方法看起来很脏,所以我很乐意不必使用它.
kkthxbai xon1c
我正在尝试进行videoObjects存储在a中的Z-Index重新排序vector.计划是确定videoObject哪个将被放置在第一个位置vector,擦除它然后将其插入第一个位置.不幸的是,该erase()功能总是导致错误的内存访
这是我的代码:
testApp.h:
vector<videoObject> videoObjects;
vector<videoObject>::iterator itVid;
Run Code Online (Sandbox Code Playgroud)
testApp.cpp:
// Get the videoObject which relates to the user event
for(itVid = videoObjects.begin(); itVid != videoObjects.end(); ++itVid) {
if(videoObjects.at(itVid - videoObjects.begin()).isInside(ofPoint(tcur.getX(), tcur.getY()))) {
videoObjects.erase(itVid);
}
}
Run Code Online (Sandbox Code Playgroud)
这应该是如此简单,但我只是没有看到我在哪里走错了路.