带有嵌套演员的 cluttermm 鼠标事件

cluttermm mouse events with nested actors

我有以下使用 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();
}

儿童演员在点击时应打印 "Child:XX"。但他们根本没有反应。将父类型更改为(已弃用)Clutter::Group 时,点击行为符合预期,但 FlowLayout 不再起作用。我在这里错过了什么?我是否需要在父 actor 上启用某些功能才能启用容器功能?

编辑: 用 c 代码替换父 actor 的行为符合预期:

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" 信号。显然,这阻止了按钮按下信号的传播。所以我分叉了 cluttermm 并更改了绑定。

查看此提交: https://github.com/underdoeg/cluttermm/commit/0e40c9c673c2415ab1b4eb90dd1ebcd95a515810