diff --git a/src/gui/ContextMenu.cxx b/src/gui/ContextMenu.cxx index 11e09e475..cf142255f 100644 --- a/src/gui/ContextMenu.cxx +++ b/src/gui/ContextMenu.cxx @@ -181,7 +181,7 @@ bool ContextMenu::sendSelectionUp() return false; _selectedItem--; - sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1); + sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, _id); return true; } @@ -192,7 +192,7 @@ bool ContextMenu::sendSelectionDown() return false; _selectedItem++; - sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1); + sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, _id); return true; } @@ -203,7 +203,7 @@ bool ContextMenu::sendSelectionFirst() return false; _selectedItem = 0; - sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1); + sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, _id); return true; } @@ -214,7 +214,7 @@ bool ContextMenu::sendSelectionLast() return false; _selectedItem = int(_entries.size()) - 1; - sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1); + sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, _id); return true; } @@ -375,7 +375,7 @@ void ContextMenu::sendSelection() // Send any command associated with the selection _selectedItem = item; - sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1); + sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, _id); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/ContextMenu.hxx b/src/gui/ContextMenu.hxx index 28d485f1a..40858f8b9 100644 --- a/src/gui/ContextMenu.hxx +++ b/src/gui/ContextMenu.hxx @@ -45,6 +45,9 @@ class ContextMenu : public Dialog, public CommandSender const VariantList& items, int cmd = 0, int width = 0); virtual ~ContextMenu() = default; + /** Set the parent widget's ID */ + void setID(uInt32 id) { _id = id; } + /** Add the given items to the widget. */ void addItems(const VariantList& items); @@ -121,6 +124,7 @@ class ContextMenu : public Dialog, public CommandSender ColorId _scrollUpColor{kColor}, _scrollDnColor{kColor}; int _cmd{0}; + int _id{-1}; uInt32 _xorig{0}, _yorig{0}; uInt32 _maxWidth{0}; diff --git a/src/gui/PopUpWidget.cxx b/src/gui/PopUpWidget.cxx index 6b530f6d1..9cc233060 100644 --- a/src/gui/PopUpWidget.cxx +++ b/src/gui/PopUpWidget.cxx @@ -50,6 +50,14 @@ PopUpWidget::PopUpWidget(GuiObject* boss, const GUI::Font& font, myMenu = make_unique(this, font, list, cmd, w); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void PopUpWidget::setID(uInt32 id) +{ + myMenu->setID(id); + + Widget::setID(id); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PopUpWidget::addItems(const VariantList& items) { @@ -219,5 +227,5 @@ void PopUpWidget::drawWidget(bool hilite) TextAlign align = (_font.getStringWidth(name) > w-6) ? TextAlign::Right : TextAlign::Left; s.drawString(_font, name, x+2, _y+myTextY, w-6, - !(isEnabled() && onTop) ? kColor : kTextColor, align); + !(isEnabled() && onTop) ? kColor : _changed ? kDbgChangedTextColor : kTextColor, align); } diff --git a/src/gui/PopUpWidget.hxx b/src/gui/PopUpWidget.hxx index f79e575f8..955263f5f 100644 --- a/src/gui/PopUpWidget.hxx +++ b/src/gui/PopUpWidget.hxx @@ -41,6 +41,8 @@ class PopUpWidget : public Widget, public CommandSender const string& label, int labelWidth = 0, int cmd = 0); virtual ~PopUpWidget() = default; + void setID(uInt32 id); + int getTop() const override { return _y + 1; } int getBottom() const override { return _y + 1 + getHeight(); }