1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListCtrl sample
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation
17 // For compilers that support precompilation, includes "wx/wx.h".
18 #include "wx/wxprec.h"
29 #include "mondrian.xpm"
32 #include "wx/listctrl.h"
33 #include "wx/timer.h" // for wxStopWatch
36 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
37 EVT_MENU(BUSY_ON
, MyFrame::BusyOn
)
38 EVT_MENU(BUSY_OFF
, MyFrame::BusyOff
)
39 EVT_MENU(LIST_QUIT
, MyFrame::OnQuit
)
40 EVT_MENU(LIST_ABOUT
, MyFrame::OnAbout
)
41 EVT_MENU(LIST_LIST_VIEW
, MyFrame::OnListView
)
42 EVT_MENU(LIST_REPORT_VIEW
, MyFrame::OnReportView
)
43 EVT_MENU(LIST_ICON_VIEW
, MyFrame::OnIconView
)
44 EVT_MENU(LIST_ICON_TEXT_VIEW
, MyFrame::OnIconTextView
)
45 EVT_MENU(LIST_SMALL_ICON_VIEW
, MyFrame::OnSmallIconView
)
46 EVT_MENU(LIST_SMALL_ICON_TEXT_VIEW
, MyFrame::OnSmallIconTextView
)
47 EVT_MENU(LIST_DESELECT_ALL
, MyFrame::OnDeselectAll
)
48 EVT_MENU(LIST_SELECT_ALL
, MyFrame::OnSelectAll
)
49 EVT_MENU(LIST_DELETE_ALL
, MyFrame::OnDeleteAll
)
50 EVT_MENU(LIST_SORT
, MyFrame::OnSort
)
53 BEGIN_EVENT_TABLE(MyListCtrl
, wxListCtrl
)
54 EVT_LIST_BEGIN_DRAG(LIST_CTRL
, MyListCtrl::OnBeginDrag
)
55 EVT_LIST_BEGIN_RDRAG(LIST_CTRL
, MyListCtrl::OnBeginRDrag
)
56 EVT_LIST_BEGIN_LABEL_EDIT(LIST_CTRL
, MyListCtrl::OnBeginLabelEdit
)
57 EVT_LIST_END_LABEL_EDIT(LIST_CTRL
, MyListCtrl::OnEndLabelEdit
)
58 EVT_LIST_DELETE_ITEM(LIST_CTRL
, MyListCtrl::OnDeleteItem
)
59 EVT_LIST_DELETE_ALL_ITEMS(LIST_CTRL
, MyListCtrl::OnDeleteAllItems
)
60 EVT_LIST_GET_INFO(LIST_CTRL
, MyListCtrl::OnGetInfo
)
61 EVT_LIST_SET_INFO(LIST_CTRL
, MyListCtrl::OnSetInfo
)
62 EVT_LIST_ITEM_SELECTED(LIST_CTRL
, MyListCtrl::OnSelected
)
63 EVT_LIST_ITEM_DESELECTED(LIST_CTRL
, MyListCtrl::OnDeselected
)
64 EVT_LIST_KEY_DOWN(LIST_CTRL
, MyListCtrl::OnListKeyDown
)
65 EVT_LIST_ITEM_ACTIVATED(LIST_CTRL
, MyListCtrl::OnActivated
)
66 EVT_LIST_COL_CLICK(LIST_CTRL
, MyListCtrl::OnColClick
)
71 int wxCALLBACK
MyCompareFunction(long item1
, long item2
, long sortData
)
77 // `Main program' equivalent, creating windows and returning main app frame
78 bool MyApp::OnInit(void)
80 // Create the main frame window
81 MyFrame
*frame
= new MyFrame((wxFrame
*) NULL
, "wxListCtrl Test", 50, 50, 450, 340);
83 // This reduces flicker effects - even better would be to define OnEraseBackground
84 // to do nothing. When the list control's scrollbars are show or hidden, the
85 // frame is sent a background erase event.
86 frame
->SetBackgroundColour( *wxWHITE
);
89 frame
->SetIcon( wxICON(mondrian
) );
91 // Make an image list containing large icons
92 m_imageListNormal
= new wxImageList(32, 32, TRUE
);
93 m_imageListSmall
= new wxImageList(16, 16, TRUE
);
96 m_imageListNormal
->Add( wxIcon("icon1", wxBITMAP_TYPE_ICO_RESOURCE
) );
97 m_imageListNormal
->Add( wxIcon("icon2", wxBITMAP_TYPE_ICO_RESOURCE
) );
98 m_imageListNormal
->Add( wxIcon("icon3", wxBITMAP_TYPE_ICO_RESOURCE
) );
99 m_imageListNormal
->Add( wxIcon("icon4", wxBITMAP_TYPE_ICO_RESOURCE
) );
100 m_imageListNormal
->Add( wxIcon("icon5", wxBITMAP_TYPE_ICO_RESOURCE
) );
101 m_imageListNormal
->Add( wxIcon("icon6", wxBITMAP_TYPE_ICO_RESOURCE
) );
102 m_imageListNormal
->Add( wxIcon("icon7", wxBITMAP_TYPE_ICO_RESOURCE
) );
103 m_imageListNormal
->Add( wxIcon("icon8", wxBITMAP_TYPE_ICO_RESOURCE
) );
104 m_imageListNormal
->Add( wxIcon("icon9", wxBITMAP_TYPE_ICO_RESOURCE
) );
106 m_imageListSmall
->Add( wxIcon("iconsmall", wxBITMAP_TYPE_ICO_RESOURCE
) );
110 #include "bitmaps/toolbrai.xpm"
111 m_imageListNormal
->Add( wxIcon( toolbrai_xpm
) );
112 #include "bitmaps/toolchar.xpm"
113 m_imageListNormal
->Add( wxIcon( toolchar_xpm
) );
114 #include "bitmaps/tooldata.xpm"
115 m_imageListNormal
->Add( wxIcon( tooldata_xpm
) );
116 #include "bitmaps/toolnote.xpm"
117 m_imageListNormal
->Add( wxIcon( toolnote_xpm
) );
118 #include "bitmaps/tooltodo.xpm"
119 m_imageListNormal
->Add( wxIcon( tooltodo_xpm
) );
120 #include "bitmaps/toolchec.xpm"
121 m_imageListNormal
->Add( wxIcon( toolchec_xpm
) );
122 #include "bitmaps/toolgame.xpm"
123 m_imageListNormal
->Add( wxIcon( toolgame_xpm
) );
124 #include "bitmaps/tooltime.xpm"
125 m_imageListNormal
->Add( wxIcon( tooltime_xpm
) );
126 #include "bitmaps/toolword.xpm"
127 m_imageListNormal
->Add( wxIcon( toolword_xpm
) );
129 #include "bitmaps/small1.xpm"
130 m_imageListSmall
->Add( wxIcon( small1_xpm
) );
135 wxMenu
*file_menu
= new wxMenu
;
137 file_menu
->Append(LIST_LIST_VIEW
, "&List view\tF1");
138 file_menu
->Append(LIST_REPORT_VIEW
, "&Report view\tF2");
139 file_menu
->Append(LIST_ICON_VIEW
, "&Icon view\tF3");
140 file_menu
->Append(LIST_ICON_TEXT_VIEW
, "Icon view with &text\tF4");
141 file_menu
->Append(LIST_SMALL_ICON_VIEW
, "&Small icon view\tF5");
142 file_menu
->Append(LIST_SMALL_ICON_TEXT_VIEW
, "Small icon &view with text\tF6");
143 file_menu
->Append(LIST_DESELECT_ALL
, "&Deselect All");
144 file_menu
->Append(LIST_SELECT_ALL
, "S&elect All");
145 file_menu
->AppendSeparator();
146 file_menu
->Append(LIST_SORT
, "&Sort\tCtrl-S");
147 file_menu
->AppendSeparator();
148 file_menu
->Append(LIST_DELETE_ALL
, "Delete &all items");
149 file_menu
->AppendSeparator();
150 file_menu
->Append(BUSY_ON
, "&Busy cursor on");
151 file_menu
->Append(BUSY_OFF
, "&Busy cursor off");
152 file_menu
->AppendSeparator();
153 file_menu
->Append(LIST_ABOUT
, "&About");
154 file_menu
->Append(LIST_QUIT
, "E&xit\tAlt-X");
155 wxMenuBar
*menu_bar
= new wxMenuBar
;
156 menu_bar
->Append(file_menu
, "&File");
157 frame
->SetMenuBar(menu_bar
);
159 // Make a panel with a message
160 frame
->m_listCtrl
= new MyListCtrl(frame
, LIST_CTRL
, wxPoint(0, 0), wxSize(400, 200),
161 wxLC_LIST
|wxSUNKEN_BORDER
|wxLC_EDIT_LABELS
);
162 // wxLC_LIST|wxLC_USER_TEXT|wxSUNKEN_BORDER); // wxLC_USER_TEXT requires app to supply all text on demand
163 frame
->m_logWindow
= new wxTextCtrl(frame
, -1, "", wxPoint(0, 0), wxSize(400, 200), wxTE_MULTILINE
|wxSUNKEN_BORDER
);
165 wxLayoutConstraints
*c
= new wxLayoutConstraints
;
166 c
->top
.SameAs (frame
, wxTop
);
167 c
->left
.SameAs (frame
, wxLeft
);
168 c
->right
.SameAs (frame
, wxRight
);
169 c
->height
.PercentOf (frame
, wxHeight
, 66);
170 frame
->m_listCtrl
->SetConstraints(c
);
172 c
= new wxLayoutConstraints
;
173 c
->top
.Below (frame
->m_listCtrl
);
174 c
->left
.SameAs (frame
, wxLeft
);
175 c
->right
.SameAs (frame
, wxRight
);
176 c
->bottom
.SameAs (frame
, wxBottom
);
177 frame
->m_logWindow
->SetConstraints(c
);
178 frame
->SetAutoLayout(TRUE
);
180 for ( int i
=0; i
< 30; i
++)
183 wxSprintf(buf
, _T("Item %d"), i
);
184 frame
->m_listCtrl
->InsertItem(i
, buf
);
187 frame
->CreateStatusBar(3);
188 frame
->SetStatusText("", 0);
198 // My frame constructor
199 MyFrame::MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
):
200 wxFrame(frame
, -1, title
, wxPoint(x
, y
), wxSize(w
, h
))
202 m_listCtrl
= (MyListCtrl
*) NULL
;
203 m_logWindow
= (wxTextCtrl
*) NULL
;
206 MyFrame::~MyFrame(void)
208 delete wxGetApp().m_imageListNormal
;
209 delete wxGetApp().m_imageListSmall
;
212 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
))
217 void MyFrame::BusyOn(wxCommandEvent
& WXUNUSED(event
))
222 void MyFrame::BusyOff(wxCommandEvent
& WXUNUSED(event
))
227 void MyFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
))
229 wxMessageDialog
dialog(this, "List test sample\nJulian Smart (c) 1997",
230 "About list test", wxOK
|wxCANCEL
);
235 void MyFrame::OnDeselectAll(wxCommandEvent
& WXUNUSED(event
))
237 int n
= m_listCtrl
->GetItemCount();
238 for (int i
= 0; i
< n
; i
++)
239 m_listCtrl
->SetItemState(i
,0,wxLIST_STATE_SELECTED
);
242 void MyFrame::OnSelectAll(wxCommandEvent
& WXUNUSED(event
))
244 int n
= m_listCtrl
->GetItemCount();
245 for (int i
= 0; i
< n
; i
++)
246 m_listCtrl
->SetItemState(i
,wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
249 void MyFrame::OnListView(wxCommandEvent
& WXUNUSED(event
))
251 m_listCtrl
->DeleteAllItems();
252 m_logWindow
->Clear();
253 m_listCtrl
->SetSingleStyle(wxLC_LIST
);
254 m_listCtrl
->SetImageList((wxImageList
*) NULL
, wxIMAGE_LIST_NORMAL
);
255 m_listCtrl
->SetImageList((wxImageList
*) NULL
, wxIMAGE_LIST_SMALL
);
257 for ( int i
=0; i
< 30; i
++)
260 wxSprintf(buf
, _T("Item %d"), i
);
261 m_listCtrl
->InsertItem(i
, buf
);
265 void MyFrame::OnReportView(wxCommandEvent
& WXUNUSED(event
))
267 m_listCtrl
->DeleteAllItems();
268 m_listCtrl
->DeleteAllColumns();
269 m_logWindow
->Clear();
271 m_listCtrl
->SetSingleStyle(wxLC_REPORT
);
272 m_listCtrl
->SetImageList((wxImageList
*) NULL
, wxIMAGE_LIST_NORMAL
);
273 m_listCtrl
->SetImageList(wxGetApp().m_imageListSmall
, wxIMAGE_LIST_SMALL
);
275 m_listCtrl
->InsertColumn(0, "Column 1"); // , wxLIST_FORMAT_LEFT, 140);
276 m_listCtrl
->InsertColumn(1, "Column 2"); // , wxLIST_FORMAT_LEFT, 140);
277 m_listCtrl
->InsertColumn(2, "One More Column (2)"); // , wxLIST_FORMAT_LEFT, 140);
279 // to speed up inserting we hide the control temporarily
285 static const int NUM_ITEMS
= 3000;
286 for ( int i
= 0; i
< NUM_ITEMS
; i
++ )
288 buf
.Printf(_T("This is item %d"), i
);
289 long tmp
= m_listCtrl
->InsertItem(i
, buf
, 0);
290 m_listCtrl
->SetItemData(tmp
, i
);
292 buf
.Printf(_T("Col 1, item %d"), i
);
293 tmp
= m_listCtrl
->SetItem(i
, 1, buf
);
295 buf
.Printf(_T("Item %d in column 2"), i
);
296 tmp
= m_listCtrl
->SetItem(i
, 2, buf
);
299 m_logWindow
->WriteText(wxString::Format(_T("%d items inserted in %ldms\n"),
300 NUM_ITEMS
, sw
.Time()));
303 // we leave all mask fields to 0 and only change the colour
306 item
.SetTextColour(*wxRED
);
307 m_listCtrl
->SetItem( item
);
310 item
.SetTextColour(*wxGREEN
);
311 m_listCtrl
->SetItem( item
);
313 item
.SetTextColour(*wxLIGHT_GREY
);
314 item
.SetFont(*wxITALIC_FONT
);
315 item
.SetBackgroundColour(*wxRED
);
316 m_listCtrl
->SetItem( item
);
318 m_listCtrl
->SetTextColour(*wxBLUE
);
319 m_listCtrl
->SetBackgroundColour(*wxLIGHT_GREY
);
321 m_listCtrl
->SetColumnWidth( 0, wxLIST_AUTOSIZE
);
322 m_listCtrl
->SetColumnWidth( 1, wxLIST_AUTOSIZE
);
323 m_listCtrl
->SetColumnWidth( 2, wxLIST_AUTOSIZE
);
326 void MyFrame::OnIconView(wxCommandEvent
& WXUNUSED(event
))
328 m_listCtrl
->DeleteAllItems();
329 m_logWindow
->Clear();
330 m_listCtrl
->SetSingleStyle(wxLC_ICON
);
331 m_listCtrl
->SetImageList(wxGetApp().m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
332 m_listCtrl
->SetImageList(wxGetApp().m_imageListSmall
, wxIMAGE_LIST_SMALL
);
334 for ( int i
=0; i
< 9; i
++)
336 m_listCtrl
->InsertItem(i
, i
);
340 void MyFrame::OnIconTextView(wxCommandEvent
& WXUNUSED(event
))
342 m_listCtrl
->DeleteAllItems();
343 m_logWindow
->Clear();
344 m_listCtrl
->SetSingleStyle(wxLC_ICON
);
345 m_listCtrl
->SetImageList(wxGetApp().m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
346 m_listCtrl
->SetImageList(wxGetApp().m_imageListSmall
, wxIMAGE_LIST_SMALL
);
348 for ( int i
=0; i
< 9; i
++)
351 wxSprintf(buf
, _T("Label %d"), i
);
352 m_listCtrl
->InsertItem(i
, buf
, i
);
356 void MyFrame::OnSmallIconView(wxCommandEvent
& WXUNUSED(event
))
358 m_listCtrl
->DeleteAllItems();
359 m_logWindow
->Clear();
360 m_listCtrl
->SetSingleStyle(wxLC_SMALL_ICON
);
361 m_listCtrl
->SetImageList(wxGetApp().m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
362 m_listCtrl
->SetImageList(wxGetApp().m_imageListSmall
, wxIMAGE_LIST_SMALL
);
364 for ( int i
=0; i
< 9; i
++)
366 m_listCtrl
->InsertItem(i
, 0);
370 void MyFrame::OnSmallIconTextView(wxCommandEvent
& WXUNUSED(event
))
372 m_listCtrl
->DeleteAllItems();
373 m_logWindow
->Clear();
374 m_listCtrl
->SetSingleStyle(wxLC_SMALL_ICON
);
375 m_listCtrl
->SetImageList(wxGetApp().m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
376 m_listCtrl
->SetImageList(wxGetApp().m_imageListSmall
, wxIMAGE_LIST_SMALL
);
378 for ( int i
=0; i
< 9; i
++)
380 m_listCtrl
->InsertItem(i
, "Label", 0);
384 void MyFrame::OnSort(wxCommandEvent
& WXUNUSED(event
))
388 m_listCtrl
->SortItems(MyCompareFunction
, 0);
390 m_logWindow
->WriteText(wxString::Format(_T("Sorting %d items took %ld ms\n"),
391 m_listCtrl
->GetItemCount(),
395 void MyFrame::OnDeleteAll(wxCommandEvent
& WXUNUSED(event
))
399 m_listCtrl
->DeleteAllItems();
401 m_logWindow
->WriteText(wxString::Format(_T("Deleting %d items took %ld ms\n"),
402 m_listCtrl
->GetItemCount(),
408 void MyListCtrl::OnColClick(wxListEvent
& event
)
410 if ( !wxGetApp().GetTopWindow() )
413 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
418 msg
.Printf( "OnColumnClick at %d.\n", event
.GetColumn() );
419 text
->WriteText(msg
);
422 void MyListCtrl::OnBeginDrag(wxListEvent
& event
)
424 if ( !wxGetApp().GetTopWindow() )
427 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
432 msg
.Printf( "OnBeginDrag at %d,%d.\n", event
.m_pointDrag
.x
, event
.m_pointDrag
.y
);
433 text
->WriteText(msg
);
436 void MyListCtrl::OnBeginRDrag(wxListEvent
& event
)
438 if ( !wxGetApp().GetTopWindow() )
441 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
446 msg
.Printf( "OnBeginRDrag at %d,%d.\n", event
.m_pointDrag
.x
, event
.m_pointDrag
.y
);
447 text
->WriteText(msg
);
450 void MyListCtrl::OnBeginLabelEdit(wxListEvent
& event
)
452 if ( !wxGetApp().GetTopWindow() )
455 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
459 text
->WriteText("OnBeginLabelEdit: ");
460 text
->WriteText(event
.m_item
.m_text
);
461 text
->WriteText("\n");
464 void MyListCtrl::OnEndLabelEdit(wxListEvent
& event
)
466 if ( !wxGetApp().GetTopWindow() )
469 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
473 text
->WriteText("OnEndLabelEdit: ");
474 text
->WriteText(event
.m_item
.m_text
);
475 text
->WriteText("\n");
478 void MyListCtrl::OnDeleteItem(wxListEvent
& WXUNUSED(event
))
480 if ( !wxGetApp().GetTopWindow() )
483 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
487 text
->WriteText("OnDeleteItem\n");
490 void MyListCtrl::OnDeleteAllItems(wxListEvent
& WXUNUSED(event
))
492 if ( !wxGetApp().GetTopWindow() )
495 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
499 text
->WriteText("OnDeleteAllItems\n");
502 void MyListCtrl::OnGetInfo(wxListEvent
& event
)
504 if ( !wxGetApp().GetTopWindow() )
507 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
511 text
->WriteText("OnGetInfo\n");
513 (*text
) << "OnGetInfo (" << event
.m_item
.m_itemId
<< ", " << event
.m_item
.m_col
<< ")";
514 if ( event
.m_item
.m_mask
& wxLIST_MASK_STATE
)
515 (*text
) << " wxLIST_MASK_STATE";
516 if ( event
.m_item
.m_mask
& wxLIST_MASK_TEXT
)
517 (*text
) << " wxLIST_MASK_TEXT";
518 if ( event
.m_item
.m_mask
& wxLIST_MASK_IMAGE
)
519 (*text
) << " wxLIST_MASK_IMAGE";
520 if ( event
.m_item
.m_mask
& wxLIST_MASK_DATA
)
521 (*text
) << " wxLIST_MASK_DATA";
522 if ( event
.m_item
.m_mask
& wxLIST_SET_ITEM
)
523 (*text
) << " wxLIST_SET_ITEM";
524 if ( event
.m_item
.m_mask
& wxLIST_MASK_WIDTH
)
525 (*text
) << " wxLIST_MASK_WIDTH";
526 if ( event
.m_item
.m_mask
& wxLIST_MASK_FORMAT
)
527 (*text
) << " wxLIST_MASK_WIDTH";
529 if ( event
.m_item
.m_mask
& wxLIST_MASK_TEXT
)
531 event
.m_item
.m_text
= "My callback text";
536 void MyListCtrl::OnSetInfo(wxListEvent
& WXUNUSED(event
))
538 if ( !wxGetApp().GetTopWindow() )
541 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
545 text
->WriteText("OnSetInfo\n");
548 void MyListCtrl::OnSelected(wxListEvent
& event
)
550 if ( !wxGetApp().GetTopWindow() )
553 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
557 if ( GetWindowStyle() & wxLC_REPORT
)
560 info
.m_itemId
= event
.m_itemIndex
;
562 info
.m_mask
= wxLIST_MASK_TEXT
;
565 *text
<< "Value of the 2nd field of the selected item: "
566 << info
.m_text
<< '\n';
570 wxFAIL_MSG("wxListCtrl::GetItem() failed");
574 text
->WriteText("OnSelected\n");
577 void MyListCtrl::OnDeselected(wxListEvent
& WXUNUSED(event
))
579 if ( !wxGetApp().GetTopWindow() )
582 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
586 text
->WriteText("OnDeselected\n");
589 void MyListCtrl::OnActivated(wxListEvent
& WXUNUSED(event
))
591 if ( !wxGetApp().GetTopWindow() )
594 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
598 text
->WriteText("OnActivated\n");
601 void MyListCtrl::OnListKeyDown(wxListEvent
& event
)
603 if ( !wxGetApp().GetTopWindow() )
606 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
610 text
->WriteText("OnListKeyDown\n");