Add wxEVT_DIRCTRL_FILEACTIVATED wxDirCtrl event.
Allow processing double clicks on the files in the directory control. Closes #15208. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74003 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
40c7c7f473
commit
4d623b67ee
@ -635,6 +635,7 @@ All (GUI):
|
||||
- Implement clipping for wxSVGFileDC (Steve Benbow).
|
||||
- Add wxDirCtrl::GetPath() (troelsk).
|
||||
- Add wxEVT_DIRCTRL_SELECTIONCHANGED event (troelsk).
|
||||
- Add wxEVT_DIRCTRL_FILEACTIVATED event (troelsk).
|
||||
- Add wxControl::GetSizeFromTextSize() (Manuel Martin).
|
||||
- Optionally allow showing tooltips for disabled ribbon buttons (wxBen).
|
||||
- Add wxTL_NO_HEADER style to wxTreeListCtrl (robboto).
|
||||
|
@ -110,6 +110,7 @@ public:
|
||||
void OnBeginEditItem(wxTreeEvent &event );
|
||||
void OnEndEditItem(wxTreeEvent &event );
|
||||
void OnTreeSelChange(wxTreeEvent &event);
|
||||
void OnItemActivated(wxTreeEvent &event);
|
||||
void OnSize(wxSizeEvent &event );
|
||||
|
||||
// Try to expand as much of the given path as possible.
|
||||
@ -210,11 +211,13 @@ private:
|
||||
};
|
||||
|
||||
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_DIRCTRL_SELECTIONCHANGED, wxTreeEvent );
|
||||
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_DIRCTRL_FILEACTIVATED, wxTreeEvent );
|
||||
|
||||
#define wx__DECLARE_DIRCTRL_EVT(evt, id, fn) \
|
||||
wx__DECLARE_EVT1(wxEVT_DIRCTRL_ ## evt, id, wxTreeEventHandler(fn))
|
||||
|
||||
#define EVT_DIRCTRL_SELECTIONCHANGED(id, fn) wx__DECLARE_DIRCTRL_EVT(SELECTIONCHANGED, id, fn)
|
||||
#define EVT_DIRCTRL_FILEACTIVATED(id, fn) wx__DECLARE_DIRCTRL_EVT(FILEACTIVATED, id, fn)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDirFilterListCtrl
|
||||
@ -310,6 +313,7 @@ extern WXDLLIMPEXP_DATA_CORE(wxFileIconsTable *) wxTheFileIconsTable;
|
||||
|
||||
// old wxEVT_COMMAND_* constants
|
||||
#define wxEVT_COMMAND_DIRCTRL_SELECTIONCHANGED wxEVT_DIRCTRL_SELECTIONCHANGED
|
||||
#define wxEVT_COMMAND_DIRCTRL_FILEACTIVATED wxEVT_DIRCTRL_FILEACTIVATED
|
||||
|
||||
#endif
|
||||
// _WX_DIRCTRLG_H_
|
||||
|
@ -57,6 +57,9 @@ enum
|
||||
Notice that this event is generated even for the changes done by the
|
||||
program itself and not only those done by the user.
|
||||
@since 2.9.5
|
||||
@event{EVT_DIRCTRL_FILEACTIVATED(id, func)}
|
||||
The user activated a file by double-clicking or pressing Enter.
|
||||
@since 2.9.5
|
||||
*/
|
||||
class wxGenericDirCtrl : public wxControl
|
||||
{
|
||||
@ -279,3 +282,4 @@ public:
|
||||
};
|
||||
|
||||
wxEventType wxEVT_DIRCTRL_SELECTIONCHANGED;
|
||||
wxEventType wxEVT_DIRCTRL_FILEACTIVATED;
|
||||
|
@ -113,6 +113,7 @@ protected:
|
||||
void OnCheckBox(wxCommandEvent& event);
|
||||
void OnRadioBox(wxCommandEvent& event);
|
||||
void OnSelChanged(wxTreeEvent& event);
|
||||
void OnFileActivated(wxTreeEvent& event);
|
||||
|
||||
// reset the control parameters
|
||||
void Reset();
|
||||
@ -157,6 +158,7 @@ BEGIN_EVENT_TABLE(DirCtrlWidgetsPage, WidgetsPage)
|
||||
EVT_CHECKBOX(wxID_ANY, DirCtrlWidgetsPage::OnCheckBox)
|
||||
EVT_RADIOBOX(wxID_ANY, DirCtrlWidgetsPage::OnRadioBox)
|
||||
EVT_DIRCTRL_SELECTIONCHANGED(DirCtrlPage_Ctrl, DirCtrlWidgetsPage::OnSelChanged)
|
||||
EVT_DIRCTRL_FILEACTIVATED(DirCtrlPage_Ctrl, DirCtrlWidgetsPage::OnFileActivated)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// ============================================================================
|
||||
@ -377,4 +379,15 @@ void DirCtrlWidgetsPage::OnSelChanged(wxTreeEvent& event)
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void DirCtrlWidgetsPage::OnFileActivated(wxTreeEvent& event)
|
||||
{
|
||||
if ( m_dirCtrl )
|
||||
{
|
||||
wxLogMessage("File activated \"%s\"",
|
||||
m_dirCtrl->GetPath(event.GetItem()));
|
||||
}
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
#endif // wxUSE_DIRDLG
|
||||
|
@ -107,6 +107,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 +449,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,12 +712,34 @@ 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
|
||||
{
|
||||
event.Skip();
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user