X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/40c7c7f4732b4bb234a222d0a7b4bfdc67a26f7e..36a0190ebd5bd9a7302f60f6dcd608b80574e21c:/src/generic/dirctrlg.cpp diff --git a/src/generic/dirctrlg.cpp b/src/generic/dirctrlg.cpp index 824c836942..5b6e3871c1 100644 --- a/src/generic/dirctrlg.cpp +++ b/src/generic/dirctrlg.cpp @@ -4,7 +4,6 @@ // Author: Harm van der Heijden, Robert Roebling, Julian Smart // Modified by: // Created: 12/12/98 -// RCS-ID: $Id$ // Copyright: (c) Harm van der Heijden, Robert Roebling and Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -107,6 +106,7 @@ bool wxIsDriveAvailable(const wxString& dirName); // ---------------------------------------------------------------------------- wxDEFINE_EVENT( wxEVT_DIRCTRL_SELECTIONCHANGED, wxTreeEvent ); +wxDEFINE_EVENT( wxEVT_DIRCTRL_FILEACTIVATED, wxTreeEvent ); // ---------------------------------------------------------------------------- // wxGetAvailableDrives, for WINDOWS, DOS, OS2, MAC, UNIX (returns "/") @@ -448,6 +448,7 @@ BEGIN_EVENT_TABLE(wxGenericDirCtrl, wxControl) EVT_TREE_BEGIN_LABEL_EDIT (wxID_TREECTRL, wxGenericDirCtrl::OnBeginEditItem) EVT_TREE_END_LABEL_EDIT (wxID_TREECTRL, wxGenericDirCtrl::OnEndEditItem) EVT_TREE_SEL_CHANGED (wxID_TREECTRL, wxGenericDirCtrl::OnTreeSelChange) + EVT_TREE_ITEM_ACTIVATED (wxID_TREECTRL, wxGenericDirCtrl::OnItemActivated) EVT_SIZE (wxGenericDirCtrl::OnSize) END_EVENT_TABLE() @@ -710,13 +711,35 @@ void wxGenericDirCtrl::OnTreeSelChange(wxTreeEvent &event) changedEvent.SetClientObject(m_treeCtrl->GetItemData(event.GetItem())); if (GetEventHandler()->SafelyProcessEvent(changedEvent) && !changedEvent.IsAllowed()) - { event.Veto(); - } else + event.Skip(); +} + +void wxGenericDirCtrl::OnItemActivated(wxTreeEvent &event) +{ + wxTreeItemId treeid = event.GetItem(); + const wxDirItemData *data = GetItemData(treeid); + + if (data->m_isDir) { + // is dir event.Skip(); } + else + { + // is file + wxTreeEvent changedEvent(wxEVT_DIRCTRL_FILEACTIVATED, GetId()); + + changedEvent.SetEventObject(this); + changedEvent.SetItem(treeid); + changedEvent.SetClientObject(m_treeCtrl->GetItemData(treeid)); + + if (GetEventHandler()->SafelyProcessEvent(changedEvent) && !changedEvent.IsAllowed()) + event.Veto(); + else + event.Skip(); + } } void wxGenericDirCtrl::OnExpandItem(wxTreeEvent &event)