mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Avoided TreeView consuming return key presses if the selected item can't be opened.
This commit is contained in:
parent
0a7b960b09
commit
aa408bd982
2 changed files with 12 additions and 4 deletions
|
|
@ -742,10 +742,18 @@ void TreeView::scrollToKeepItemVisible (TreeViewItem* item)
|
|||
}
|
||||
}
|
||||
|
||||
void TreeView::toggleOpenSelectedItem()
|
||||
bool TreeView::toggleOpenSelectedItem()
|
||||
{
|
||||
if (TreeViewItem* const firstSelected = getSelectedItem (0))
|
||||
firstSelected->setOpen (! firstSelected->isOpen());
|
||||
{
|
||||
if (firstSelected->mightContainSubItems())
|
||||
{
|
||||
firstSelected->setOpen (! firstSelected->isOpen());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void TreeView::moveOutOfSelectedItem()
|
||||
|
|
@ -822,7 +830,7 @@ bool TreeView::keyPressed (const KeyPress& key)
|
|||
if (key == KeyPress::endKey) { moveSelectedRow (0x3fffffff); return true; }
|
||||
if (key == KeyPress::pageUpKey) { moveByPages (-1); return true; }
|
||||
if (key == KeyPress::pageDownKey) { moveByPages (1); return true; }
|
||||
if (key == KeyPress::returnKey) { toggleOpenSelectedItem(); return true; }
|
||||
if (key == KeyPress::returnKey) { return toggleOpenSelectedItem(); }
|
||||
if (key == KeyPress::leftKey) { moveOutOfSelectedItem(); return true; }
|
||||
if (key == KeyPress::rightKey) { moveIntoSelectedItem(); return true; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -875,7 +875,7 @@ private:
|
|||
void hideDragHighlight() noexcept;
|
||||
void handleDrag (const StringArray&, const SourceDetails&);
|
||||
void handleDrop (const StringArray&, const SourceDetails&);
|
||||
void toggleOpenSelectedItem();
|
||||
bool toggleOpenSelectedItem();
|
||||
void moveOutOfSelectedItem();
|
||||
void moveIntoSelectedItem();
|
||||
void moveByPages (int numPages);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue