cnjinhao / nana

a modern C++ GUI library
https://nana.acemind.cn
Boost Software License 1.0
2.3k stars 331 forks source link

Error in mouse position when dragging file #627

Closed uuiid closed 2 years ago

uuiid commented 3 years ago

Error in mouse position when dragging file 拖拽文件时传入鼠标位置错误 image

class tree : public nana::form {
    nana::treebox p_tree;
    nana::place p_layout;
    nana::menu p_menu;

public:
    tree()
        : p_tree(*this)
        , p_layout(*this)
        , p_menu()
    {
        p_layout.div("<tree>");

        auto k_f = p_tree.first();

        auto tset = p_tree.insert("root", "root");
        p_tree.insert("r2", "2");
        p_tree.insert("r3", "3");
        p_tree.insert("r4", "4");

        // SPDLOG_INFO(tset.level());
        tset.append("1", "1");
        tset.append("2", "2");
        tset.append("3", "3");
        tset.append("4", "4");
        p_layout.field("tree") << p_tree;
        p_menu.append("clear", [this](const nana::menu::item_proxy& in_) { p_tree.clear(); });
        p_menu.append("clear root", [this](const nana::menu::item_proxy& in_) { p_tree.find("root").clear(); });
        p_menu.append("clear null", [this, tset](const nana::menu::item_proxy& in_) { p_tree.erase("root"); });
        p_tree.events().mouse_down(nana::menu_popuper(p_menu));

        p_tree.enable_dropfiles(true);
        p_tree.events().mouse_dropfiles.connect([this](const nana::arg_dropfiles& in_) {
            // nana::detail::bedrock::instance().wd_manager().calc_window_point();
            // auto pos = in_.pos;
            // nana::API::calc_screen_point(in_.window_handle,pos);
            this->p_menu.popup(in_.window_handle, in_.pos.x, in_.pos.y);
        });

        p_layout.collocate();
    };
};
cnjinhao commented 2 years ago

The PR for the issue is merged