*/
virtual wxTreeItemId GetFirstVisibleItem() const;
+ /**
+ Returns the item last clicked or otherwise selected.
+ Unlike GetSelection(), it can be used whether or not
+ the control has the @c wxTR_MULTIPLE style.
+
+ @since 2.9.1
+ */
+ virtual wxTreeItemId GetFocusedItem() const;
+
/**
Returns the normal image list.
*/
/**
Returns the selection, or an invalid item if there is no selection. This
function only works with the controls without @c wxTR_MULTIPLE style,
- use GetSelections() for the controls which do have this style.
+ use GetSelections() for the controls which do have this style
+ or, if a single item is wanted, use GetFocusedItem().
*/
virtual wxTreeItemId GetSelection() const;
void MyFrame::OnRename(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
CHECK_ITEM( item );
void MyFrame::OnCount(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
CHECK_ITEM( item );
void MyFrame::OnCountRec(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
CHECK_ITEM( item );
void MyFrame::DoSort(bool reverse)
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
CHECK_ITEM( item );
void MyFrame::OnHighlight(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId id = m_treeCtrl->GetSelection();
+ wxTreeItemId id = m_treeCtrl->GetFocusedItem();
CHECK_ITEM( id );
void MyFrame::OnDump(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId root = m_treeCtrl->GetSelection();
+ wxTreeItemId root = m_treeCtrl->GetFocusedItem();
CHECK_ITEM( root );
void MyFrame::OnSelect(wxCommandEvent& WXUNUSED(event))
{
- m_treeCtrl->SelectItem(m_treeCtrl->GetSelection());
+ m_treeCtrl->SelectItem(m_treeCtrl->GetFocusedItem());
}
void MyFrame::OnSelectRoot(wxCommandEvent& WXUNUSED(event))
void MyFrame::DoSetBold(bool bold)
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
CHECK_ITEM( item );
void MyFrame::OnDelete(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
CHECK_ITEM( item );
void MyFrame::OnDeleteChildren(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
CHECK_ITEM( item );
{
unsigned int indent = m_treeCtrl->GetSpacing();
if (indent < 100)
+ {
m_treeCtrl->SetSpacing( indent+5 );
+ m_treeCtrl->Refresh();
+ }
}
void MyFrame::OnDecSpacing(wxCommandEvent& WXUNUSED(event))
{
unsigned int indent = m_treeCtrl->GetSpacing();
if (indent > 10)
+ {
m_treeCtrl->SetSpacing( indent-5 );
+ m_treeCtrl->Refresh();
+ }
}
void MyFrame::OnToggleIcon(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
CHECK_ITEM( item );
void MyFrame::OnToggleState(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
CHECK_ITEM( item );
void MyFrame::DoShowRelativeItem(TreeFunc1_t pfn, const wxString& label)
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
CHECK_ITEM( item );