| @@ -1681,3 +1681,11 @@ bool PopupMenu::MenuItemIterator::next() | |||||
| return true; | return true; | ||||
| } | } | ||||
| void PopupMenu::MenuItemIterator::addItemTo (PopupMenu& targetMenu) | |||||
| { | |||||
| targetMenu.items.add (new Item (itemId, itemName, isEnabled, isTicked, customImage, | |||||
| customColour != nullptr ? *customColour : Colours::black, customColour != nullptr, | |||||
| nullptr, | |||||
| subMenu, commandManager)); | |||||
| } | |||||
| @@ -397,6 +397,9 @@ public: | |||||
| */ | */ | ||||
| bool next(); | bool next(); | ||||
| /** Adds an item to the target menu which has all the properties of this item. */ | |||||
| void addItemTo (PopupMenu& targetMenu); | |||||
| //============================================================================== | //============================================================================== | ||||
| String itemName; | String itemName; | ||||
| const PopupMenu* subMenu; | const PopupMenu* subMenu; | ||||
| @@ -127,6 +127,9 @@ public: | |||||
| /** The time that this mouse-event occurred. */ | /** The time that this mouse-event occurred. */ | ||||
| const Time eventTime; | const Time eventTime; | ||||
| /** The time that the corresponding mouse-down event occurred. */ | |||||
| const Time mouseDownTime; | |||||
| /** The source device that generated this event. */ | /** The source device that generated this event. */ | ||||
| MouseInputSource& source; | MouseInputSource& source; | ||||
| @@ -312,7 +315,6 @@ public: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| const Point<int> mouseDownPos; | const Point<int> mouseDownPos; | ||||
| const Time mouseDownTime; | |||||
| const uint8 numberOfClicks, wasMovedSinceMouseDown; | const uint8 numberOfClicks, wasMovedSinceMouseDown; | ||||
| MouseEvent& operator= (const MouseEvent&); | MouseEvent& operator= (const MouseEvent&); | ||||
| @@ -242,7 +242,7 @@ public: | |||||
| String getTooltip() | String getTooltip() | ||||
| { | { | ||||
| Rectangle<int> pos; | Rectangle<int> pos; | ||||
| if (TreeViewItem* const item = findItemAt (getMouseXYRelative().getY(), pos)) | |||||
| if (TreeViewItem* const item = findItemAt (getMouseXYRelative().y, pos)) | |||||
| return item->getTooltip(); | return item->getTooltip(); | ||||
| return owner.getTooltip(); | return owner.getTooltip(); | ||||
| @@ -94,6 +94,27 @@ public: | |||||
| */ | */ | ||||
| void removeSubItem (int index, bool deleteItem = true); | void removeSubItem (int index, bool deleteItem = true); | ||||
| /** Sorts the list of sub-items using a standard array comparator. | |||||
| This will use a comparator object to sort the elements into order. The comparator | |||||
| object must have a method of the form: | |||||
| @code | |||||
| int compareElements (TreeViewItem* first, TreeViewItem* second); | |||||
| @endcode | |||||
| ..and this method must return: | |||||
| - a value of < 0 if the first comes before the second | |||||
| - a value of 0 if the two objects are equivalent | |||||
| - a value of > 0 if the second comes before the first | |||||
| To improve performance, the compareElements() method can be declared as static or const. | |||||
| */ | |||||
| template <class ElementComparator> | |||||
| void sortSubItems (ElementComparator& comparator) | |||||
| { | |||||
| subItems.sort (comparator); | |||||
| } | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Returns the TreeView to which this item belongs. */ | /** Returns the TreeView to which this item belongs. */ | ||||
| TreeView* getOwnerView() const noexcept { return ownerView; } | TreeView* getOwnerView() const noexcept { return ownerView; } | ||||