diff --git a/src/gui/ContextMenu.cxx b/src/gui/ContextMenu.cxx index 4785270f0..42fae421d 100644 --- a/src/gui/ContextMenu.cxx +++ b/src/gui/ContextMenu.cxx @@ -168,6 +168,13 @@ const string& ContextMenu::getSelectedName() const return (_selectedItem >= 0) ? _entries[_selectedItem].first : EmptyString; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ContextMenu::setSelectedName(const string& name) +{ + if(_selectedItem >= 0) + _entries[_selectedItem].first = name; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const Variant& ContextMenu::getSelectedTag() const { diff --git a/src/gui/ContextMenu.hxx b/src/gui/ContextMenu.hxx index 7e80ca927..06013a59b 100644 --- a/src/gui/ContextMenu.hxx +++ b/src/gui/ContextMenu.hxx @@ -71,6 +71,7 @@ class ContextMenu : public Dialog, public CommandSender /** Accessor methods for the currently selected item. */ int getSelected() const; const string& getSelectedName() const; + void setSelectedName(const string& name); const Variant& getSelectedTag() const; /** This dialog uses its own positioning, so we override Dialog::setPosition() */ diff --git a/src/gui/PopUpWidget.cxx b/src/gui/PopUpWidget.cxx index 980e37e3e..c398374be 100644 --- a/src/gui/PopUpWidget.cxx +++ b/src/gui/PopUpWidget.cxx @@ -40,7 +40,7 @@ PopUpWidget::PopUpWidget(GuiObject* boss, const GUI::Font& font, _textcolorhi = kTextColor; // do not highlight the label setTextFilter([](char c) { - return (isprint(c) && c != '\"') || c == '\x1c' || c == '\x1d'; // DEGREE || ELLIPSIS + return isprint(c) && c != '\"' || c == '\x1c' || c == '\x1d'; // DEGREE || ELLIPSIS }); setEditable(false); @@ -122,6 +122,12 @@ const string& PopUpWidget::getSelectedName() const return myMenu->getSelectedName(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void PopUpWidget::setSelectedName(const string& name) +{ + myMenu->setSelectedName(name); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const Variant& PopUpWidget::getSelectedTag() const { diff --git a/src/gui/PopUpWidget.hxx b/src/gui/PopUpWidget.hxx index a5cc150e8..8d34114b3 100644 --- a/src/gui/PopUpWidget.hxx +++ b/src/gui/PopUpWidget.hxx @@ -48,6 +48,8 @@ class PopUpWidget : public EditableWidget /** Add the given items to the widget. */ void addItems(const VariantList& items); + ///** Get the items of the widget. */ + //const VariantList& getItems(const VariantList& items) const; /** Various selection methods passed directly to the underlying menu See ContextMenu.hxx for more information. */ @@ -59,6 +61,7 @@ class PopUpWidget : public EditableWidget int getSelected() const; const string& getSelectedName() const; + void setSelectedName(const string& name); const Variant& getSelectedTag() const; bool wantsFocus() const override { return true; }