我有以下使用cluttermm 1.24的代码片段:

#include <cluttermm.h>

int main(int argc, char *argv[]){
    Clutter::init(argc, argv);

    auto stage = Clutter::Stage::create();
    stage->set_size(1280, 720);

    //create a parent actor
    auto parent = Clutter::Actor::create();
    parent->set_size(1240, 720);
    parent->set_margins(20, 20, 20, 20);

    //create children
    for(unsigned i=0; i<84; i++){
        auto child = Clutter::Actor::create();
        child->set_name(std::to_string(i).c_str());
        child->set_size(80, 80);
        child->set_background_color(Clutter::Color(80));
        child->set_reactive(true);
        child->signal_button_press_event().connect([child](Clutter::ButtonEvent* evt){
            g_print("Child: %s", child->get_name().c_str());
            return true;
        });

        parent->add_child(child);
    }

    auto layout = Clutter::FlowLayout::create(Clutter::FlowOrientation::FLOW_HORIZONTAL);
    layout->set_column_spacing(20);
    layout->set_row_spacing(20);
    parent->set_layout_manager(layout);
    stage->add_child(parent);

    stage->show();

    Clutter::main();
}

点击时,儿童演员应打印“儿童:XX”。但他们一点反应都没有。将父类型更改为(不推荐使用的)杂波::组时,单击行为与预期一致,但FlowLayout不再工作。我错过了什么?我需要在父actor上启用一些东西来启用容器功能吗?
编辑:
用c代码替换父参与者的行为与预期一致:
auto parent = clutter_actor_new ();
clutter_actor_set_layout_manager (parent, CLUTTER_LAYOUT_MANAGER(layout->gobj()));
clutter_actor_set_size (parent, 1240, 720);
clutter_actor_add_child (CLUTTER_ACTOR(stage->gobj()), parent);
...
clutter_actor_add_child (parent, child->gobj());

最佳答案

我发现了问题。Cluttermm包装了被弃用的“pick”信号。显然这阻止了按键信号的传播。所以我用叉子叉了一堆东西,换了装订。
查看此提交:
https://github.com/underdoeg/cluttermm/commit/0e40c9c673c2415ab1b4eb90dd1ebcd95a515810

关于c++ - 带有嵌套actor的cluttermm鼠标事件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38846842/

10-11 16:47