propagate key event from listctrl to its parent
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1727 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
06d20283af
commit
51cc4dad89
@ -1191,7 +1191,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
long x = dc.DeviceToLogicalX( (long)event.GetX() );
|
long x = dc.DeviceToLogicalX( (long)event.GetX() );
|
||||||
long y = dc.DeviceToLogicalY( (long)event.GetY() );
|
long y = dc.DeviceToLogicalY( (long)event.GetY() );
|
||||||
|
|
||||||
// Did we actually hit an item ?
|
/* Did we actually hit an item ? */
|
||||||
long hitResult = 0;
|
long hitResult = 0;
|
||||||
wxNode *node = m_lines.First();
|
wxNode *node = m_lines.First();
|
||||||
wxListLineData *line = (wxListLineData *) NULL;
|
wxListLineData *line = (wxListLineData *) NULL;
|
||||||
@ -1383,27 +1383,27 @@ void wxListMainWindow::OnArrowChar( wxListLineData *newCurrent, bool shiftDown )
|
|||||||
|
|
||||||
void wxListMainWindow::OnChar( wxKeyEvent &event )
|
void wxListMainWindow::OnChar( wxKeyEvent &event )
|
||||||
{
|
{
|
||||||
|
wxWindow *parent = GetParent();
|
||||||
|
|
||||||
|
/* we send a list_key event up */
|
||||||
wxListEvent le( wxEVT_COMMAND_LIST_KEY_DOWN, GetParent()->GetId() );
|
wxListEvent le( wxEVT_COMMAND_LIST_KEY_DOWN, GetParent()->GetId() );
|
||||||
le.m_code = event.KeyCode();
|
le.m_code = event.KeyCode();
|
||||||
|
|
||||||
wxWindow *parent = GetParent();
|
|
||||||
le.SetEventObject( parent );
|
le.SetEventObject( parent );
|
||||||
wxEvtHandler *handler = parent->GetEventHandler();
|
parent->GetEventHandler()->ProcessEvent( le );
|
||||||
handler->ProcessEvent( le );
|
|
||||||
|
|
||||||
// pass the original CHAR event to the ctrl too
|
/* we propagate the key event up */
|
||||||
handler->ProcessEvent( event );
|
wxKeyEvent ke( wxEVT_KEY_DOWN );
|
||||||
|
ke.m_shiftDown = event.m_shiftDown;
|
||||||
|
ke.m_controlDown = event.m_controlDown;
|
||||||
|
ke.m_altDown = event.m_altDown;
|
||||||
|
ke.m_metaDown = event.m_metaDown;
|
||||||
|
ke.m_keyCode = event.m_keyCode;
|
||||||
|
ke.m_x = event.m_x;
|
||||||
|
ke.m_y = event.m_y;
|
||||||
|
ke.SetEventObject( parent );
|
||||||
|
if (parent->GetEventHandler()->ProcessEvent( ke )) return;
|
||||||
|
|
||||||
/*
|
/* no item -> nothing to do */
|
||||||
if (event.KeyCode() == WXK_TAB)
|
|
||||||
{
|
|
||||||
if (event.ShiftDown())
|
|
||||||
TravPrev( &event );
|
|
||||||
else
|
|
||||||
TravNext( &event );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (!m_current)
|
if (!m_current)
|
||||||
{
|
{
|
||||||
event.Skip();
|
event.Skip();
|
||||||
@ -1439,7 +1439,10 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
case WXK_PRIOR:
|
case WXK_PRIOR:
|
||||||
{
|
{
|
||||||
int steps = 0;
|
int steps = 0;
|
||||||
if (m_mode & wxLC_REPORT) { steps = m_visibleLines-1; }
|
if (m_mode & wxLC_REPORT)
|
||||||
|
{
|
||||||
|
steps = m_visibleLines-1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
@ -1455,7 +1458,10 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
case WXK_NEXT:
|
case WXK_NEXT:
|
||||||
{
|
{
|
||||||
int steps = 0;
|
int steps = 0;
|
||||||
if (m_mode & wxLC_REPORT) { steps = m_visibleLines-1; }
|
if (m_mode & wxLC_REPORT)
|
||||||
|
{
|
||||||
|
steps = m_visibleLines-1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int pos = 0; wxNode *node = m_lines.First();
|
int pos = 0; wxNode *node = m_lines.First();
|
||||||
@ -1491,8 +1497,8 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
{
|
{
|
||||||
m_current->ReverseHilight();
|
m_current->ReverseHilight();
|
||||||
RefreshLine( m_current );
|
RefreshLine( m_current );
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case WXK_INSERT:
|
case WXK_INSERT:
|
||||||
{
|
{
|
||||||
if (!(m_mode & wxLC_SINGLE_SEL))
|
if (!(m_mode & wxLC_SINGLE_SEL))
|
||||||
@ -1507,8 +1513,8 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
UnfocusLine( oldCurrent );
|
UnfocusLine( oldCurrent );
|
||||||
FocusLine( m_current );
|
FocusLine( m_current );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case WXK_RETURN:
|
case WXK_RETURN:
|
||||||
case WXK_EXECUTE:
|
case WXK_EXECUTE:
|
||||||
{
|
{
|
||||||
@ -1517,8 +1523,8 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
le.m_itemIndex = GetIndexOfLine( m_current );
|
le.m_itemIndex = GetIndexOfLine( m_current );
|
||||||
m_current->GetItem( 0, le.m_item );
|
m_current->GetItem( 0, le.m_item );
|
||||||
GetParent()->GetEventHandler()->ProcessEvent( le );
|
GetParent()->GetEventHandler()->ProcessEvent( le );
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
event.Skip();
|
event.Skip();
|
||||||
@ -2721,7 +2727,6 @@ long wxListCtrl::InsertColumn( long col, const wxString &heading,
|
|||||||
item.m_mask |= wxLIST_MASK_WIDTH;
|
item.m_mask |= wxLIST_MASK_WIDTH;
|
||||||
item.m_width = width;
|
item.m_width = width;
|
||||||
}
|
}
|
||||||
;
|
|
||||||
item.m_format = format;
|
item.m_format = format;
|
||||||
|
|
||||||
return InsertColumn( col, item );
|
return InsertColumn( col, item );
|
||||||
@ -2794,9 +2799,12 @@ void wxListCtrl::SetBackgroundColour( const wxColour &colour )
|
|||||||
m_mainWin->SetBackgroundColour( colour );
|
m_mainWin->SetBackgroundColour( colour );
|
||||||
m_mainWin->m_dirty = TRUE;
|
m_mainWin->m_dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_headerWin)
|
if (m_headerWin)
|
||||||
|
{
|
||||||
m_headerWin->SetBackgroundColour( colour );
|
m_headerWin->SetBackgroundColour( colour );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxListCtrl::SetForegroundColour( const wxColour &colour )
|
void wxListCtrl::SetForegroundColour( const wxColour &colour )
|
||||||
{
|
{
|
||||||
@ -2805,9 +2813,12 @@ void wxListCtrl::SetForegroundColour( const wxColour &colour )
|
|||||||
m_mainWin->SetForegroundColour( colour );
|
m_mainWin->SetForegroundColour( colour );
|
||||||
m_mainWin->m_dirty = TRUE;
|
m_mainWin->m_dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_headerWin)
|
if (m_headerWin)
|
||||||
|
{
|
||||||
m_headerWin->SetForegroundColour( colour );
|
m_headerWin->SetForegroundColour( colour );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxListCtrl::SetFont( const wxFont &font )
|
void wxListCtrl::SetFont( const wxFont &font )
|
||||||
{
|
{
|
||||||
@ -2816,7 +2827,10 @@ void wxListCtrl::SetFont( const wxFont &font )
|
|||||||
m_mainWin->SetFont( font );
|
m_mainWin->SetFont( font );
|
||||||
m_mainWin->m_dirty = TRUE;
|
m_mainWin->m_dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_headerWin)
|
if (m_headerWin)
|
||||||
|
{
|
||||||
m_headerWin->SetFont( font );
|
m_headerWin->SetFont( font );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user