From: Karsten Ballüder Date: Mon, 14 Jun 1999 20:02:01 +0000 (+0000) Subject: Fixed the keyboard selection handling (Please remember to maintain m_Selecting X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/daa69da89ec06c5fb4d80c62597ed7fb1eb54a4b Fixed the keyboard selection handling (Please remember to maintain m_Selecting when Starting/Ending/Discarding selection!!!). Fixed a LineBreak() related bug. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2792 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/richedit/TODO b/samples/richedit/TODO index a38796245b..bba3a36887 100644 --- a/samples/richedit/TODO +++ b/samples/richedit/TODO @@ -12,14 +12,11 @@ TODO ===================================================================== -- typedef wxCoords CoordType ?? - - merge RecalulateXXX and Layout() into one -- remove UpdateCursorScreenCoords() which is no longer needed - UNDO!! - replacement of llist in window - - selection highlighting is a bit broken + Improve speed! (See layout problem below!) - wxlwindow needs to shrink scrollbar range when window contents get removed @@ -29,9 +26,6 @@ Improve speed! (See layout problem below!) - The import of a private data object does not work yet, we need to get the objects back from the string. -- Changing default settings in Clear() or changing/inserting/deleting - a wxLayoutObject needs to update the m_StyleInfo in all lines, only - then can we start using that one. - update rectangle (needs support in wxllist and wxWindows) --> needs a bit of fixing still @@ -39,6 +33,5 @@ Improve speed! (See layout problem below!) offset handling seems a bit dodgy, white shadow to top/left of cursor - DragNDrop - - Update docs, do full rtf/html editing. - - Verify html export. + - Verify/fix html export. diff --git a/samples/richedit/wxllist.cpp b/samples/richedit/wxllist.cpp index e2c3613977..73540de76c 100644 --- a/samples/richedit/wxllist.cpp +++ b/samples/richedit/wxllist.cpp @@ -2048,7 +2048,10 @@ wxLayoutList::LineBreak(void) height = m_CursorLine->GetHeight(); m_CursorLine = m_CursorLine->Break(m_CursorPos.x, this); - m_CursorPos.y++; + if(m_CursorLine->GetPreviousLine() == NULL) + m_FirstLine = m_CursorLine; + if(m_CursorPos.x > 0) + m_CursorPos.y++; m_CursorPos.x = 0; // The following code will produce a height which is guaranteed to diff --git a/samples/richedit/wxlwindow.cpp b/samples/richedit/wxlwindow.cpp index acbc6890d8..42d6681100 100644 --- a/samples/richedit/wxlwindow.cpp +++ b/samples/richedit/wxlwindow.cpp @@ -225,7 +225,9 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event) PrepareDC( dc ); if ( eventId != WXLOWIN_MENU_MOUSEMOVE ) { - // moving the mouse in a window shouldn't give it the focus! + // moving the mouse in a window shouldn't give it the focus! + // Oh yes! wxGTK's focus handling is so broken, that this is the + // only sensible way to go. SetFocus(); } @@ -311,6 +313,7 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event) if ( m_llist->HasSelection() ) { m_llist->DiscardSelection(); + m_Selecting = false; DoPaint(); // TODO: we don't have to redraw everything! } @@ -413,11 +416,16 @@ wxLayoutWindow::OnChar(wxKeyEvent& event) } #endif +#if 0 // Force m_Selecting to be false if shift is no longer // pressed. OnKeyUp() cannot catch all Shift-Up events. - if(!event.ShiftDown()) + if(m_Selecting && !event.ShiftDown()) + { m_Selecting = false; - + m_llist->EndSelection(); + } +#endif + // If we deleted the selection here, we must not execute the // deletion in Delete/Backspace handling. bool deletedSelection = false; @@ -436,17 +444,23 @@ wxLayoutWindow::OnChar(wxKeyEvent& event) // + starts selection if ( IsDirectionKey(keyCode) ) { - if ( !m_Selecting ) - { - m_Selecting = true; - m_llist->StartSelection(); - } - else + if ( m_Selecting ) { // just continue the old selection - if(! event.ShiftDown() ) + if( event.ShiftDown() ) + m_llist->ContinueSelection(); + else + { m_llist->DiscardSelection(); + m_Selecting = false; + } + } + else if( event.ShiftDown() ) + { + m_Selecting = true; + m_llist->StartSelection(); } + } // If needed, make cursor visible: