:在Excel中,对选定的块执行剪切时,在粘贴之前不会移动值。剪切后,如果发生除粘贴以外的任何事件(不是全部,而是大部分),则块将被删除
不
感动的
我正试图实现同样的想法。我有两个功能:
void MyFrame::OnCut(wxCommandEvent& evt);
void MyFrame::OnPaste(wxCommandEvent& evt);
还定义了以下事件:
wxDEFINE_EVENT(CUT_EVENT, wxCommandEvent);
wxDEFINE_EVENT(PASTE_EVENT, wxCommandEvent);
中的代码
由2个区块构成。调用剪切时应执行第一个块,调用粘贴时应执行第二个块。
void MyFrame::OnCut(wxCommandEvent& evt)
{
if (evt.GetEventType() != PASTE_EVENT){
m_CutEventCalled = true;
//Some code here
}
if (evt.GetEventType() == PASTE_EVENT)
//Some code here
m_CutEventCalled = false;
}
}
void MyFrame::OnPaste(wxCommandEvent& evt)
{
//Some other code
if(m_CutEventCalled){
wxCommandEvent PasteEvent;
PasteEvent.SetEventType(PASTE_EVENT);
PasteEvent.SetEventObject(this);
Bind(PASTE_EVENT, &MyFrame::OnCut, this);
wxPostEvent(this, PasteEvent);
}
}
到目前为止,如果Cut事件为
立即
然后是粘贴事件。然而,我想要
m_CutEventCalled=false
bool MyFrame::ProcessEvent(wxEvent & evt)
{
static wxEvent* s_lastEvent = NULL;
if (&evt == s_lastEvent)
return false;
int evtID = evt.GetId();
//if this part of the code exists the whole thing doesnt work
//otherwise it only works cut immediately followed by paste
if (evtID != ID_PASTE && evtID != ID_CUT)
m_CutEventCalled = false;
return wxMDIChildFrame::ProcessEvent(evt);
}
我的想法是,除了ID_粘贴和ID_剪切之外,任何ID事件都应该重置
m_CutEventCalled=false
ProcessEvent
换句话说,我怎么知道呢
any
剪切事件之后发生了粘贴事件以外的事件。一个解决办法是我可以
m_CutEventCalled=false
在所有其他事件处理程序中,这似乎不是一个优雅的解决方案。