void wxCodeCompletionBox::OnLeftDClick(wxMouseEvent& event) { // Check the scroll area if(m_scrollBottomRect.Contains(event.GetPosition())) { DoScrollDown(); } else if(m_scrollTopRect.Contains(event.GetPosition())) { DoScrollUp(); } else { for(size_t i = 0; i < m_entries.size(); ++i) { if(m_entries.at(i)->m_itemRect.Contains(event.GetPosition())) { m_index = i; InsertSelection(); CallAfter(&wxCodeCompletionBox::DoDestroy); return; } } } }
void wxCodeCompletionBox::StcKeyDown(wxKeyEvent& event) { switch(event.GetKeyCode()) { case WXK_UP: DoScrollUp(); break; case WXK_DOWN: DoScrollDown(); break; case WXK_PAGEDOWN: { DoPgDown(); break; } case WXK_PAGEUP: { DoPgUp(); break; } case WXK_ESCAPE: case WXK_LEFT: case WXK_RIGHT: case WXK_HOME: case WXK_END: case WXK_DELETE: case WXK_NUMPAD_DELETE: case WXK_ALT: case WXK_WINDOWS_LEFT: case WXK_WINDOWS_RIGHT: case WXK_CONTROL: DoDestroy(); event.Skip(); break; case WXK_TAB: case WXK_RETURN: case WXK_NUMPAD_ENTER: // Insert the selection InsertSelection(); DoDestroy(); break; default: event.Skip(); break; } }
void wxCodeCompletionBox::ShowCompletionBox(wxStyledTextCtrl* ctrl, const wxCodeCompletionBoxEntry::Vec_t& entries) { m_index = 0; m_stc = ctrl; m_allEntries = entries; // Keep the start position if(m_startPos == wxNOT_FOUND) { m_startPos = m_stc->WordStartPosition(m_stc->GetCurrentPos(), true); } // Filter all duplicate entries from the list (based on simple string match) RemoveDuplicateEntries(); // Filter results based on user input FilterResults(); // If we got a single match - insert it if((m_entries.size() == 1) && (m_flags & kInsertSingleMatch)) { // single match InsertSelection(); DoDestroy(); return; } if(m_entries.empty()) { // no entries to display DoDestroy(); return; } DoShowCompletionBox(); if(m_stc) { // Set the focus back to the completion control m_stc->CallAfter(&wxStyledTextCtrl::SetFocus); } // Display the help window DoDisplayTipWindow(); }
void wxCodeCompletionBox::StcKeyDown(wxKeyEvent& event) { switch(event.GetKeyCode()) { case WXK_UP: DoScrollUp(); break; case WXK_DOWN: DoScrollDown(); break; case WXK_PAGEDOWN: { int newindex = m_index + (LINES_PER_PAGE - 1); if(newindex >= (int)m_entries.size()) { newindex = (int)m_entries.size() - 1; } // only refresh if there was an actual change if(m_index != newindex) { m_index = newindex; DoDisplayTipWindow(); Refresh(); } break; } case WXK_PAGEUP: { int newindex = m_index - (LINES_PER_PAGE - 1); if(newindex < 0) { newindex = 0; } // only refresh if there was an actual change if(m_index != newindex) { m_index = newindex; DoDisplayTipWindow(); Refresh(); } break; } case WXK_ESCAPE: case WXK_LEFT: case WXK_RIGHT: case WXK_HOME: case WXK_END: case WXK_DELETE: case WXK_NUMPAD_DELETE: case WXK_ALT: case WXK_WINDOWS_LEFT: case WXK_WINDOWS_RIGHT: case WXK_CONTROL: DoDestroy(); event.Skip(); break; case WXK_TAB: case WXK_RETURN: case WXK_NUMPAD_ENTER: // Insert the selection InsertSelection(); DoDestroy(); break; default: event.Skip(); break; } }