Fixed two minor bugs. Still more than enough left. Quite some new ones.:-(

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2769 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Karsten Ballüder 1999-06-13 17:44:22 +00:00
parent 96c5bd7fc4
commit d9939b3d99
2 changed files with 36 additions and 33 deletions

View File

@ -415,6 +415,7 @@ void
wxLayoutWindow::OnChar(wxKeyEvent& event) wxLayoutWindow::OnChar(wxKeyEvent& event)
{ {
int keyCode = event.KeyCode(); int keyCode = event.KeyCode();
bool ctrlDown = event.ControlDown();
#ifdef WXLAYOUT_DEBUG #ifdef WXLAYOUT_DEBUG
if(keyCode == WXK_F1) if(keyCode == WXK_F1)
@ -424,32 +425,34 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
} }
#endif #endif
wxASSERT_MSG( !m_Selecting || event.ShiftDown(), // Force m_Selecting to be false if shift is no longer
"m_Selecting is normally reset in OnKeyUp() when Shift " // pressed. OnKeyUp() cannot catch all Shift-Up events.
"goes up!" ); if(!event.ShiftDown())
m_Selecting = false;
if ( !m_Selecting && m_llist->HasSelection() ) // pressing any non-arrow key optionally replaces the selection:
{ if(m_AutoDeleteSelection
// pressing any non-arrow key replaces the selection && !m_Selecting
if ( !IsDirectionKey(keyCode) ) && m_llist->HasSelection()
{ && ! IsDirectionKey(keyCode)
&& ! (event.AltDown() || ctrlDown)
)
m_llist->DeleteSelection(); m_llist->DeleteSelection();
}
else if ( !event.ShiftDown() )
{
m_llist->DiscardSelection();
}
}
// <Shift>+<arrow> starts selection // <Shift>+<arrow> starts selection
if ( event.ShiftDown() && IsDirectionKey(keyCode) ) if ( IsDirectionKey(keyCode) )
{ {
if ( !m_Selecting ) if ( !m_Selecting )
{ {
m_Selecting = true; m_Selecting = true;
m_llist->StartSelection(); m_llist->StartSelection();
} }
//else: just continue the old selection else
{
// just continue the old selection
if(! event.ShiftDown() )
m_llist->DiscardSelection();
}
} }
// If needed, make cursor visible: // If needed, make cursor visible:
@ -461,7 +464,6 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
cursor, etc. It's default will process all keycodes causing cursor, etc. It's default will process all keycodes causing
modifications to the buffer, but only if editing is allowed. modifications to the buffer, but only if editing is allowed.
*/ */
bool ctrlDown = event.ControlDown();
switch(keyCode) switch(keyCode)
{ {
case WXK_RIGHT: case WXK_RIGHT:
@ -510,7 +512,7 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
else if( IsEditable() ) else if( IsEditable() )
{ {
/* First, handle control keys */ /* First, handle control keys */
if(event.ControlDown() && ! event.AltDown()) if(ctrlDown && ! event.AltDown())
{ {
switch(keyCode) switch(keyCode)
{ {
@ -976,17 +978,6 @@ wxLayoutWindow::Paste(bool primary)
} }
wxTheClipboard->Close(); wxTheClipboard->Close();
} }
#if 0
/* My attempt to get the primary selection, but it does not
work. :-( */
if(text.Length() == 0)
{
wxTextCtrl tmp_tctrl(this,-1);
tmp_tctrl.Paste();
text += tmp_tctrl.GetValue();
}
#endif
} }
bool bool

View File

@ -219,6 +219,13 @@ protected:
on demand. on demand.
*/ */
int m_CursorVisibility; int m_CursorVisibility;
bool SetAutoDeleteSelection(bool enable = TRUE)
{
bool old = m_AutoDeleteSelection;
m_AutoDeleteSelection = enable;
return old;
}
private: private:
/// The layout list to be displayed. /// The layout list to be displayed.
wxLayoutList *m_llist; wxLayoutList *m_llist;
@ -243,6 +250,11 @@ private:
int m_StatusFieldCursor; int m_StatusFieldCursor;
/// a pointer to a bitmap for the background /// a pointer to a bitmap for the background
wxBitmap *m_BGbitmap; wxBitmap *m_BGbitmap;
/**@name Some configuration options */
//@{
/// Do we want to auto-replace the selection with new text?
bool m_AutoDeleteSelection;
//@}
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };