-void wxListBox::MacDoDoubleClick()
-{
- wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent(event) ;
-}
-
-void wxListBox::OnChar(wxKeyEvent& event)
-{
- if ( event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER)
- {
- wxWindow* parent = GetParent() ;
- while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL )
- parent = parent->GetParent() ;
-
- if ( parent && parent->GetDefaultItem() )
- {
- wxButton *def = wxDynamicCast(parent->GetDefaultItem(),
- wxButton);
- if ( def && def->IsEnabled() )
- {
- wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
- event.SetEventObject(def);
- def->Command(event);
- return ;
- }
- }
- event.Skip() ;
- }
- /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
- else if (event.GetKeyCode() == WXK_ESCAPE || (event.GetKeyCode() == '.' && event.MetaDown() ) )
- {
- // FIXME: look in ancestors, not just parent.
- wxWindow* win = GetParent()->FindWindow( wxID_CANCEL ) ;
- if (win)
- {
- wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
- new_event.SetEventObject( win );
- win->GetEventHandler()->ProcessEvent( new_event );
- }
- }
- else if ( event.GetKeyCode() == WXK_TAB )
- {
- wxNavigationKeyEvent new_event;
- new_event.SetEventObject( this );
- new_event.SetDirection( !event.ShiftDown() );
- /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
- new_event.SetWindowChange( event.ControlDown() );
- new_event.SetCurrentFocus( this );
- if ( !GetEventHandler()->ProcessEvent( new_event ) )
- event.Skip() ;
- }
- else if ( event.GetKeyCode() == WXK_DOWN || event.GetKeyCode() == WXK_UP )
- {
- // perform the default key handling first
- wxControl::OnKeyDown( event ) ;
-
- wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
- event.SetEventObject( this );
-
- wxArrayInt aSelections;
- int n, count = GetSelections(aSelections);
- if ( count > 0 )
- {
- n = aSelections[0];
- if ( HasClientObjectData() )
- event.SetClientObject( GetClientObject(n) );
- else if ( HasClientUntypedData() )
- event.SetClientData( GetClientData(n) );
- event.SetString( GetString(n) );
- }
- else
- {
- n = -1;
- }
-
- event.m_commandInt = n;
-
- GetEventHandler()->ProcessEvent(event);
- }
- else
- {
- if ( event.GetTimestamp() > m_lastTypeIn + 60 )
- {
- m_typeIn = wxEmptyString ;
- }
- m_lastTypeIn = event.GetTimestamp() ;
- m_typeIn += (char) event.GetKeyCode() ;
- int line = FindString(wxT("*")+m_typeIn+wxT("*")) ;
- if ( line >= 0 )
- {
- if ( GetSelection() != line )
- {
- SetSelection(line) ;
- wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
- event.SetEventObject( this );
-
- if ( HasClientObjectData() )
- event.SetClientObject( GetClientObject( line ) );
- else if ( HasClientUntypedData() )
- event.SetClientData( GetClientData(line) );
- event.SetString( GetString(line) );
-
- event.m_commandInt = line ;
-
- GetEventHandler()->ProcessEvent(event);
- }
- }
- }
-}