X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b6bfd8e8f49b13a0a81cfd849d9834c6c90feddd..4b5386874a1602f5c8b6edbfa74e4d6be619768f:/src/stc/stc.cpp.in diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index a54118ff6a..473e08d38e 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -356,8 +356,9 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename) if (len > 0) { #if wxUSE_UNICODE - wxMemoryBuffer buffer(len); + wxMemoryBuffer buffer(len+1); success = (file.Read(buffer.GetData(), len) == len); + ((char*)buffer.GetData())[len] = 0; contents = wxString(buffer, *wxConvCurrent); #else wxString buffer; @@ -465,6 +466,14 @@ void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) { void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) { wxPoint pt = evt.GetPosition(); ScreenToClient(&pt.x, &pt.y); + /* + Show context menu at event point if it's within the window, + or at caret location if not + */ + wxHitTest ht = this->HitTest(pt); + if (ht != wxHT_WINDOW_INSIDE) { + pt = this->PointFromPosition(this->GetCurrentPos()); + } m_swx->DoContextMenu(Point(pt.x, pt.y)); } @@ -492,7 +501,7 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { // printf("OnChar key:%%d consumed:%%d ctrl:%%d alt:%%d skip:%%d\n", // key, m_lastKeyDownConsumed, ctrl, alt, skip); - if ( (key <= WXK_START || key > WXK_NUMPAD_DIVIDE) && + if ( (key <= WXK_START || key > WXK_COMMAND) && !m_lastKeyDownConsumed && !skip) { m_swx->DoAddChar(key); return;