gammasoft71 / xtd

Free open-source modern C++17 / C++20 framework to create console, GUI (forms like WinForms) and unit test applications and libraries on Microsoft Windows, Apple macOS and Linux.
https://gammasoft71.github.io/xtd
MIT License
735 stars 57 forks source link

[ENHANCEMENT] Add the ability to close a dropdown combo_box programmatically #201

Closed jimorc closed 1 year ago

jimorc commented 1 year ago

Your question

Here is a test program that displays a combo_box. The list is populated when the dropdown list is displayed, and an item is selected. I would like to close the dropdown list programmatically, but I have found no method to do so. Have I missed the method, is it not possible, or does this need to be an enhancement?

#include <xtd/xtd>

using namespace xtd;
using namespace xtd::forms;

class form1 : public form {
  public:
    form1() {
      box_.drop_down += event_handler(*this, &form1::box_drop_down);
      *this << box_;
    }
    void box_drop_down(object& sender, const event_args& e)
    {
      box_.items().clear();
      box_.items().push_back({"Item 1"});
      box_.selected_index(0);
    }
  private:
    combo_box box_;
};

int main()
{
  application::run(form1 {} );
}
gammasoft71 commented 1 year ago

This feature is not implemented. I will add it ASAP.

gammasoft71 commented 1 year ago

I will add the following property :

/// @brief Gets a value indicating whether the combo box is displaying its drop-down portion.
bool dropped_down() const;

/// @brief Sets a value indicating whether the combo box is displaying its drop-down portion.
void dropped_down(bool value);
gammasoft71 commented 1 year ago

For information

jimorc commented 1 year ago

This change does not appear to work.

I changed the box_drop_down event handler as follows and get these results:

voidbox_drop_down(object&sender, consteventargs&e) { std::cout << (box.droppeddown() ? "true": "false") << '\n'; box.items().clear(); box_.items().pushback({"Item 1"}); box.selectedindex(0); box.dropped_down(false);

true is printed. OK.

The dropdown list does not close.

On 2022-10-21 16:53, Gammasoft wrote:

Closed #201 https://github.com/gammasoft71/xtd/issues/201 as completed.

— Reply to this email directly, view it on GitHub https://github.com/gammasoft71/xtd/issues/201#event-7643634688, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABET46CX2GMASOZHEFSNKHDWEL7CZANCNFSM6AAAAAARLBPAQI. You are receiving this because you authored the thread.Message ID: @.***>

-- Jim

gammasoft71 commented 1 year ago

Indeed, after checking this feature is not supported by macOS but works correctly on Windows and Linux. So I will adapt the documentation.