diff --git a/src/app/ui/file_selector.cpp b/src/app/ui/file_selector.cpp index f481fdcef..01ffbe6ba 100644 --- a/src/app/ui/file_selector.cpp +++ b/src/app/ui/file_selector.cpp @@ -191,6 +191,7 @@ public: FileSelector::FileSelector() : Window(WithTitleBar, "") + , m_navigationLocked(false) { app::WidgetLoader loader; loader.addWidgetType("filenameentry", new CustomFileNameEntryCreator); @@ -239,7 +240,7 @@ FileSelector::FileSelector() m_goBack->Click.connect(Bind(&FileSelector::onGoBack, this)); m_goForward->Click.connect(Bind(&FileSelector::onGoForward, this)); m_goUp->Click.connect(Bind(&FileSelector::onGoUp, this)); - m_location->Change.connect(Bind(&FileSelector::onLocationChange, this)); + m_location->CloseListBox.connect(Bind(&FileSelector::onLocationCloseListBox, this)); m_fileType->Change.connect(Bind(&FileSelector::onFileTypeChange, this)); m_fileList->FileSelected.connect(Bind(&FileSelector::onFileListFileSelected, this)); m_fileList->FileAccepted.connect(Bind(&FileSelector::onFileListFileAccepted, this)); @@ -610,7 +611,7 @@ void FileSelector::onGoUp() } // Hook for the 'location' combo-box -void FileSelector::onLocationChange() +void FileSelector::onLocationCloseListBox() { // When the user change the location we have to set the // current-folder in the 'fileview' widget diff --git a/src/app/ui/file_selector.h b/src/app/ui/file_selector.h index 644200636..4f4368de5 100644 --- a/src/app/ui/file_selector.h +++ b/src/app/ui/file_selector.h @@ -51,7 +51,7 @@ namespace app { void onGoBack(); void onGoForward(); void onGoUp(); - void onLocationChange(); + void onLocationCloseListBox(); void onFileTypeChange(); void onFileListFileSelected(); void onFileListFileAccepted(); diff --git a/src/ui/combobox.cpp b/src/ui/combobox.cpp index 37ac0e0d5..9dbbc40f5 100644 --- a/src/ui/combobox.cpp +++ b/src/ui/combobox.cpp @@ -85,7 +85,7 @@ ComboBox::ComboBox() m_entry = new ComboBoxEntry(this); m_button = new ComboBoxButton(); m_window = NULL; - m_selected = 0; + m_selected = -1; m_editable = false; m_clickopen = true; m_casesensitive = true; @@ -290,12 +290,16 @@ int ComboBox::getSelectedItemIndex() const void ComboBox::setSelectedItemIndex(int itemIndex) { - if (itemIndex >= 0 && (size_t)itemIndex < m_items.size()) { + if (itemIndex >= 0 && + (size_t)itemIndex < m_items.size() && + m_selected != itemIndex) { m_selected = itemIndex; ListItems::iterator it = m_items.begin() + itemIndex; ListItem* item = *it; m_entry->setText(item->getText()); + + onChange(); } } @@ -481,10 +485,8 @@ void ComboBoxListBox::onChangeSelectedItem() ListBox::onChangeSelectedItem(); int index = getSelectedIndex(); - if (isValidItem(index)) { + if (isValidItem(index)) m_comboBox->setSelectedItemIndex(index); - m_comboBox->onChange(); - } } // When the mouse is clicked we switch the visibility-status of the list-box @@ -525,6 +527,8 @@ void ComboBox::openListBox() m_window->openWindow(); getManager()->setFocus(m_listbox); + + onOpenListBox(); } } @@ -570,6 +574,11 @@ void ComboBox::onChange() Change(); } +void ComboBox::onOpenListBox() +{ + OpenListBox(); +} + void ComboBox::onCloseListBox() { CloseListBox(); diff --git a/src/ui/combobox.h b/src/ui/combobox.h index 9889a8212..0a1398a29 100644 --- a/src/ui/combobox.h +++ b/src/ui/combobox.h @@ -83,6 +83,7 @@ namespace ui { // Signals Signal0 Change; + Signal0 OpenListBox; Signal0 CloseListBox; protected: @@ -90,6 +91,7 @@ namespace ui { void onResize(ResizeEvent& ev) OVERRIDE; void onPreferredSize(PreferredSizeEvent& ev) OVERRIDE; virtual void onChange(); + virtual void onOpenListBox(); virtual void onCloseListBox(); private: