void EditorPath::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) { Object *obj = ObjectDB::get_instance(history->get_path_object(history->get_path_size() - 1)); if (!obj) return; objects.clear(); popup->clear(); _add_children_to_popup(obj); popup->set_position(get_global_position() + Vector2(0, get_size().height)); popup->set_size(Size2(get_size().width, 1)); popup->popup(); } }
void EditorPath::_gui_input(const InputEvent& p_event) { if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT && p_event.mouse_button.pressed) { Object *obj = ObjectDB::get_instance(history->get_path_object( history->get_path_size()-1)); if (!obj) return; objects.clear(); popup->clear(); _add_children_to_popup(obj); popup->set_pos( get_global_pos() + Vector2(0,get_size().height)); popup->set_size( Size2(get_size().width,1)); popup->popup(); } }
void EditorPath::_add_children_to_popup(Object* p_obj,int p_depth) { if (p_depth>8) return; List<PropertyInfo> pinfo; p_obj->get_property_list(&pinfo); for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) { if (!(E->get().usage&PROPERTY_USAGE_EDITOR)) continue; if (E->get().hint!=PROPERTY_HINT_RESOURCE_TYPE) continue; Variant value = p_obj->get(E->get().name); if (value.get_type()!=Variant::OBJECT) continue; Object *obj = value; if (!obj) continue; Ref<Texture> icon; if (has_icon(obj->get_class(),"EditorIcons")) icon=get_icon(obj->get_class(),"EditorIcons"); else icon=get_icon("Object","EditorIcons"); int index = popup->get_item_count(); popup->add_icon_item(icon,E->get().name.capitalize(),objects.size()); popup->set_item_h_offset(index,p_depth*10*EDSCALE); objects.push_back(obj->get_instance_ID()); _add_children_to_popup(obj,p_depth+1); } }