class wxListWidgetCocoaImpl;
-@interface wxNSTableDataSource : NSObject
+@interface wxNSTableDataSource : NSObject wxOSX_10_6_AND_LATER(<NSTableViewDataSource>)
{
wxListWidgetCocoaImpl* impl;
}
@end
-@interface wxNSTableView : NSTableView
+@interface wxNSTableView : NSTableView wxOSX_10_6_AND_LATER(<NSTableViewDelegate>)
{
}
virtual void UpdateLine( unsigned int n, wxListWidgetColumn* col = NULL ) ;
virtual void UpdateLineToEnd( unsigned int n);
- virtual void controlAction(WXWidget slf, void* _cmd, void *sender);
virtual void controlDoubleAction(WXWidget slf, void* _cmd, void *sender);
+
protected :
wxNSTableView* m_tableView ;
}
}
+- (void) tableViewSelectionDidChange: (NSNotification *) notification
+{
+ wxUnusedVar(notification);
+
+ int row = [self selectedRow];
+
+ if (row == -1)
+ {
+ // no row selected
+ }
+ else
+ {
+ wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
+ wxListBox *list = static_cast<wxListBox*> ( impl->GetWXPeer());
+ wxCHECK_RET( list != NULL , wxT("Listbox expected"));
+
+ wxCommandEvent event( wxEVT_COMMAND_LISTBOX_SELECTED, list->GetId() );
+
+ if ((row < 0) || (row > (int) list->GetCount())) // OS X can select an item below the last item
+ return;
+
+ if ( !list->MacGetBlockEvents() )
+ list->HandleLineEvent( row, false );
+ }
+
+}
+
@end
//
[m_tableView reloadData];
}
-void wxListWidgetCocoaImpl::controlAction(WXWidget WXUNUSED(slf),void* WXUNUSED(_cmd), void *WXUNUSED(sender))
-{
- wxListBox *list = static_cast<wxListBox*> ( GetWXPeer());
- wxCHECK_RET( list != NULL , wxT("Listbox expected"));
-
- wxCommandEvent event( wxEVT_COMMAND_LISTBOX_SELECTED, list->GetId() );
-
- int sel = [m_tableView 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 wxListWidgetCocoaImpl::controlDoubleAction(WXWidget WXUNUSED(slf),void* WXUNUSED(_cmd), void *WXUNUSED(sender))
{
wxListBox *list = static_cast<wxListBox*> ( GetWXPeer());
// setting up the true table
wxNSTableView* tableview = [[wxNSTableView alloc] init];
+ [tableview setDelegate:tableview];
// only one multi-select mode available
if ( (style & wxLB_EXTENDED) || (style & wxLB_MULTIPLE) )
[tableview setAllowsMultipleSelection:YES];