void EditTextTask::OnMouseLeftDown(wxMouseEvent &event, const wxPoint &position) { if ( m_textgraph && m_textgraph->HasPoint(position) ) { if ( event.ShiftDown() ) m_posa = GetEditPosition(position); else m_posa = m_posb = GetEditPosition(position); this->MoveCaret(); this->ShowCaret(); } else { // GraphNassiBrick *gbrick = m_view->GetBrickAtPosition(position); // if ( !gbrick ) // { // CloseTask(); // return; // } // TextGraph *textgraph = gbrick->IsOverText(position); // if ( textgraph ) // { // if ( m_textgraph ) m_textgraph->ClearEditTask(); // m_textgraph = textgraph; // m_textgraph->SetEditTask(this); // to be sure he can remove itselfe if it gets deleted // m_posa = m_posb = GetEditPosition(position); // this->MoveCaret(); // this->ShowCaret(); // } // else CloseTask(); } }
void EditTextTask::OnKeyDown(wxKeyEvent &event) { if ( m_done ) return; int code = event.GetKeyCode(); event.Skip(true); if ( code == WXK_ESCAPE ) { CloseTask(); event.Skip(false); } if ( code == WXK_DELETE || code == WXK_NUMPAD_DELETE || code == WXK_BACK ) { if ( HasSelection() ) DeleteSelection(); else if ( code == WXK_BACK ) DeleteBack(); else Delete(); event.Skip(false); } if ( code == WXK_RETURN || code == WXK_NUMPAD_ENTER ) { InsertText(_T("\n")); event.Skip(false); } if ( code == WXK_TAB ) { InsertText(_T("\t")); event.Skip(false); } }
int32_t LuaEngine::OnTimer(int64_t task_id, void* data) { UNUSE_ARG(data); LOG(INFO) << "OnTimer: task_id[" << task_id << "] TIMEOUT!!!!"; CloseTask(task_id); return -1; }
void LuaEngine::Resume(int64_t task_id) { LOG(INFO) << "resume task[" << task_id << "]"; if (task_id > 0 && co_map_[task_id] != NULL) { lua_State* co = co_map_[task_id]; int32_t ret = lua_resume(co, 0); if (ret != LUA_YIELD && ret != 0) { LOG(ERROR) << "lua_resume failed. ret[" << ret << "]"; lua_tinker::enum_stack(co); } if (ret != LUA_YIELD) CloseTask(task_id); } }
int64_t LuaEngine::CreateTask(const char* lua_func, time_t task_delay_secs) { PrintMemSize("before create_task"); // 分配定时器 int64_t task_id = heap_timer_->RegisterTimer( TimeValue(task_delay_secs), TimeValue(task_delay_secs), this, NULL); // task_id 分配失败 if (task_id <= 0) { LOG(ERROR) << "alloc timer failed!"; return -1; } // There is no explicit function to close or to destroy a thread. // Threads are subject to garbage collection, like any Lua object. lua_State* co = lua_newthread(master_state_); if (co == NULL) { LOG(ERROR) << "lua_newthread error!"; return -1; } lua_pop(master_state_, 1); co_map_[task_id] = co; // 将lua_func压入新创建的协程 lua_getglobal(co, lua_func); if (lua_isfunction(co, -1) == 0) { LOG(ERROR) << "[" << lua_func << "] is not a function"; CloseTask(task_id); return 0; } LOG(INFO) << "create task[" << task_id << "]"; LOG(INFO) << "TaskSize[" << GetTaskSize() << "]"; return task_id; }
void CpeepmBrowser::OnClose() { CloseTask(); __super::OnClose(); }
void EditTextTask::OnMouseRightUp(wxMouseEvent& event, const wxPoint &position) { CloseTask(); }
DEFINE_FINALIZE() { JL_IGNORE( fop ); CloseTask(obj); }