bool MacGetBlockEvents() const { return m_blockEvents; }
+ virtual void HandleLineEvent( unsigned int n, bool doubleClick );
protected:
// callback for derived classes which may have to insert additional data
// at a certain line - which cannot be predetermined for sorted list data
if (message == kDataBrowserItemDoubleClicked)
{
unsigned int n = owner->GetLineFromItem( this );
- wxCommandEvent event( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, list->GetId() );
- event.SetEventObject( list );
- if ( list->HasClientObjectData() )
- event.SetClientObject( list->GetClientObject(n) );
- else if ( list->HasClientUntypedData() )
- event.SetClientData( list->GetClientData(n) );
- event.SetString( list->GetString(n) );
- event.SetInt( n );
- event.SetExtraLong( 1 );
- list->HandleWindowEvent(event);
+ list->HandleLineEvent( n, true );
return;
}
}
int sel = list->GetSelection();
if ((sel < 0) || (sel > (int) list->GetCount())) // OS X can select an item below the last item (why?)
return;
- event.SetEventObject( list );
- if ( list->HasClientObjectData() )
- event.SetClientObject( list->GetClientObject( sel ) );
- else if ( list->HasClientUntypedData() )
- event.SetClientData( list->GetClientData( sel ) );
- event.SetString( list->GetString( sel ) );
- event.SetInt( sel );
- event.SetExtraLong( 1 );
- list->HandleWindowEvent(event);
+ list->HandleLineEvent( sel, false );
return;
}
- (void)setImplementation: (wxListWidgetCocoaImpl *) theImplementation;
- (wxListWidgetCocoaImpl*) implementation;
+- (void)clickedAction: (id) sender;
+- (void)doubleClickedAction: (id) sender;
@end
return impl;
}
+- (id) init
+{
+ [super init];
+ impl = NULL;
+ [self setTarget: self];
+ [self setAction: @selector(clickedAction:)];
+ [self setDoubleAction: @selector(doubleClickedAction:)];
+ return self;
+}
+
+- (void) clickedAction: (id) sender
+{
+ if ( impl )
+ {
+ wxListBox *list = static_cast<wxListBox*> ( impl->GetWXPeer());
+ wxCHECK_RET( list != NULL , wxT("Listbox expected"));
+
+ wxCommandEvent event( wxEVT_COMMAND_LISTBOX_SELECTED, list->GetId() );
+
+ int sel = [self clickedRow];
+ if ((sel < 0) || (sel > (int) list->GetCount())) // OS X can select an item below the last item (why?)
+ return;
+
+ list->HandleLineEvent( sel, false );
+ }
+}
+
+- (void) doubleClickedAction: (id) sender
+{
+ if ( impl )
+ {
+ wxListBox *list = static_cast<wxListBox*> ( impl->GetWXPeer());
+ wxCHECK_RET( list != NULL , wxT("Listbox expected"));
+
+ int sel = [self clickedRow];
+ if ((sel < 0) || (sel > (int) list->GetCount())) // OS X can select an item below the last item (why?)
+ return;
+
+ list->HandleLineEvent( sel, true );
+ }
+}
@end
int wxListWidgetCocoaImpl::ListGetSelection() const
{
- return 0;
+ return [m_tableView selectedRow];
}
int wxListWidgetCocoaImpl::ListGetSelections( wxArrayInt& aSelections ) const
{
- return 0;
+ aSelections.Empty();
+
+ int count = ListGetCount();
+
+ for ( int i = 0; i < count; ++i)
+ {
+ if ([m_tableView isRowSelected:count])
+ aSelections.Add(i);
+ }
+
+ return aSelections.Count();
}
bool wxListWidgetCocoaImpl::ListIsSelected( unsigned int n ) const
{
- return false;
+ return [m_tableView isRowSelected:n];
}
// display
GetListPeer()->UpdateLine(n);
}
+//
+// common event handling
+//
+
+void wxListBox::HandleLineEvent( unsigned int n, bool doubleClick )
+{
+ wxCommandEvent event( doubleClick ? wxEVT_COMMAND_LISTBOX_DOUBLECLICKED :
+ wxEVT_COMMAND_LISTBOX_SELECTED, GetId() );
+ event.SetEventObject( this );
+ if ( HasClientObjectData() )
+ event.SetClientObject( GetClientObject(n) );
+ else if ( HasClientUntypedData() )
+ event.SetClientData( GetClientData(n) );
+ event.SetString( GetString(n) );
+ event.SetInt( n );
+ event.SetExtraLong( 1 );
+ HandleWindowEvent(event);
+}
+
#endif // wxUSE_LISTBOX