Make sure RMB also works for resource editor in inspector, fixes #18994
This commit is contained in:
parent
f769e13c5e
commit
079c2630e2
2 changed files with 27 additions and 1 deletions
|
@ -2145,7 +2145,8 @@ void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<T
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPropertyResource::_update_menu() {
|
void EditorPropertyResource::_update_menu_items() {
|
||||||
|
|
||||||
//////////////////// UPDATE MENU //////////////////////////
|
//////////////////// UPDATE MENU //////////////////////////
|
||||||
RES res = get_edited_object()->get(get_edited_property());
|
RES res = get_edited_object()->get(get_edited_property());
|
||||||
|
|
||||||
|
@ -2287,6 +2288,11 @@ void EditorPropertyResource::_update_menu() {
|
||||||
menu->add_icon_item(icon, vformat(TTR("Convert To %s"), what), CONVERT_BASE_ID + i);
|
menu->add_icon_item(icon, vformat(TTR("Convert To %s"), what), CONVERT_BASE_ID + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorPropertyResource::_update_menu() {
|
||||||
|
|
||||||
|
_update_menu_items();
|
||||||
|
|
||||||
Rect2 gt = edit->get_global_rect();
|
Rect2 gt = edit->get_global_rect();
|
||||||
menu->set_as_minsize();
|
menu->set_as_minsize();
|
||||||
|
@ -2311,6 +2317,20 @@ void EditorPropertyResource::_sub_inspector_object_id_selected(int p_id) {
|
||||||
emit_signal("object_id_selected", get_edited_property(), p_id);
|
emit_signal("object_id_selected", get_edited_property(), p_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorPropertyResource::_button_input(const Ref<InputEvent> &p_event) {
|
||||||
|
Ref<InputEventMouseButton> mb = p_event;
|
||||||
|
if (mb.is_valid()) {
|
||||||
|
if (mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
|
||||||
|
_update_menu_items();
|
||||||
|
Vector2 pos = mb->get_global_position();
|
||||||
|
//pos = assign->get_global_transform().xform(pos);
|
||||||
|
menu->set_as_minsize();
|
||||||
|
menu->set_global_position(pos);
|
||||||
|
menu->popup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EditorPropertyResource::_open_editor_pressed() {
|
void EditorPropertyResource::_open_editor_pressed() {
|
||||||
RES res = get_edited_object()->get(get_edited_property());
|
RES res = get_edited_object()->get(get_edited_property());
|
||||||
if (res.is_valid()) {
|
if (res.is_valid()) {
|
||||||
|
@ -2598,6 +2618,7 @@ void EditorPropertyResource::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("drop_data_fw"), &EditorPropertyResource::drop_data_fw);
|
ClassDB::bind_method(D_METHOD("drop_data_fw"), &EditorPropertyResource::drop_data_fw);
|
||||||
ClassDB::bind_method(D_METHOD("_button_draw"), &EditorPropertyResource::_button_draw);
|
ClassDB::bind_method(D_METHOD("_button_draw"), &EditorPropertyResource::_button_draw);
|
||||||
ClassDB::bind_method(D_METHOD("_open_editor_pressed"), &EditorPropertyResource::_open_editor_pressed);
|
ClassDB::bind_method(D_METHOD("_open_editor_pressed"), &EditorPropertyResource::_open_editor_pressed);
|
||||||
|
ClassDB::bind_method(D_METHOD("_button_input"), &EditorPropertyResource::_button_input);
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorPropertyResource::EditorPropertyResource() {
|
EditorPropertyResource::EditorPropertyResource() {
|
||||||
|
@ -2624,6 +2645,7 @@ EditorPropertyResource::EditorPropertyResource() {
|
||||||
preview->set_margin(MARGIN_BOTTOM, -1);
|
preview->set_margin(MARGIN_BOTTOM, -1);
|
||||||
preview->set_margin(MARGIN_RIGHT, -1);
|
preview->set_margin(MARGIN_RIGHT, -1);
|
||||||
assign->add_child(preview);
|
assign->add_child(preview);
|
||||||
|
assign->connect("gui_input", this, "_button_input");
|
||||||
|
|
||||||
menu = memnew(PopupMenu);
|
menu = memnew(PopupMenu);
|
||||||
add_child(menu);
|
add_child(menu);
|
||||||
|
@ -2632,6 +2654,7 @@ EditorPropertyResource::EditorPropertyResource() {
|
||||||
menu->connect("id_pressed", this, "_menu_option");
|
menu->connect("id_pressed", this, "_menu_option");
|
||||||
edit->connect("pressed", this, "_update_menu");
|
edit->connect("pressed", this, "_update_menu");
|
||||||
hbc->add_child(edit);
|
hbc->add_child(edit);
|
||||||
|
edit->connect("gui_input", this, "_button_input");
|
||||||
|
|
||||||
file = NULL;
|
file = NULL;
|
||||||
scene_tree = NULL;
|
scene_tree = NULL;
|
||||||
|
|
|
@ -552,6 +552,8 @@ class EditorPropertyResource : public EditorProperty {
|
||||||
void _resource_selected();
|
void _resource_selected();
|
||||||
void _viewport_selected(const NodePath &p_path);
|
void _viewport_selected(const NodePath &p_path);
|
||||||
|
|
||||||
|
void _update_menu_items();
|
||||||
|
|
||||||
void _update_menu();
|
void _update_menu();
|
||||||
|
|
||||||
void _sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool);
|
void _sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool);
|
||||||
|
@ -564,6 +566,7 @@ class EditorPropertyResource : public EditorProperty {
|
||||||
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
|
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
|
||||||
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
|
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
|
||||||
|
|
||||||
|
void _button_input(const Ref<InputEvent> &p_event);
|
||||||
void _open_editor_pressed();
|
void _open_editor_pressed();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in a new issue