You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Merge pull request #22301 from YeldhamDev/button_popup_highlight
Enable toggle behaviour for buttons that trigger popups
This commit is contained in:
@@ -786,6 +786,7 @@ EditorPropertyLayers::EditorPropertyLayers() {
|
|||||||
grid->set_h_size_flags(SIZE_EXPAND_FILL);
|
grid->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
hb->add_child(grid);
|
hb->add_child(grid);
|
||||||
button = memnew(Button);
|
button = memnew(Button);
|
||||||
|
button->set_toggle_mode(true);
|
||||||
button->set_text("..");
|
button->set_text("..");
|
||||||
button->connect("pressed", this, "_button_pressed");
|
button->connect("pressed", this, "_button_pressed");
|
||||||
hb->add_child(button);
|
hb->add_child(button);
|
||||||
@@ -794,6 +795,7 @@ EditorPropertyLayers::EditorPropertyLayers() {
|
|||||||
add_child(layers);
|
add_child(layers);
|
||||||
layers->set_hide_on_checkable_item_selection(false);
|
layers->set_hide_on_checkable_item_selection(false);
|
||||||
layers->connect("id_pressed", this, "_menu_pressed");
|
layers->connect("id_pressed", this, "_menu_pressed");
|
||||||
|
layers->connect("popup_hide", button, "set_pressed", varray(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////// INT /////////////////////////
|
///////////////////// INT /////////////////////////
|
||||||
@@ -2598,6 +2600,7 @@ void EditorPropertyResource::_resource_selected() {
|
|||||||
RES res = get_edited_object()->get(get_edited_property());
|
RES res = get_edited_object()->get(get_edited_property());
|
||||||
|
|
||||||
if (res.is_null()) {
|
if (res.is_null()) {
|
||||||
|
edit->set_pressed(true);
|
||||||
_update_menu();
|
_update_menu();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2818,7 +2821,9 @@ EditorPropertyResource::EditorPropertyResource() {
|
|||||||
add_child(menu);
|
add_child(menu);
|
||||||
edit = memnew(Button);
|
edit = memnew(Button);
|
||||||
edit->set_flat(true);
|
edit->set_flat(true);
|
||||||
|
edit->set_toggle_mode(true);
|
||||||
menu->connect("id_pressed", this, "_menu_option");
|
menu->connect("id_pressed", this, "_menu_option");
|
||||||
|
menu->connect("popup_hide", edit, "set_pressed", varray(false));
|
||||||
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");
|
edit->connect("gui_input", this, "_button_input");
|
||||||
|
|||||||
@@ -831,6 +831,7 @@ ThemeEditor::ThemeEditor() {
|
|||||||
type_edit->set_h_size_flags(SIZE_EXPAND_FILL);
|
type_edit->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
type_hbc->add_child(type_edit);
|
type_hbc->add_child(type_edit);
|
||||||
type_menu = memnew(MenuButton);
|
type_menu = memnew(MenuButton);
|
||||||
|
type_menu->set_flat(false);
|
||||||
type_menu->set_text("..");
|
type_menu->set_text("..");
|
||||||
type_hbc->add_child(type_menu);
|
type_hbc->add_child(type_menu);
|
||||||
|
|
||||||
@@ -848,6 +849,7 @@ ThemeEditor::ThemeEditor() {
|
|||||||
name_edit->set_h_size_flags(SIZE_EXPAND_FILL);
|
name_edit->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
name_hbc->add_child(name_edit);
|
name_hbc->add_child(name_edit);
|
||||||
name_menu = memnew(MenuButton);
|
name_menu = memnew(MenuButton);
|
||||||
|
type_menu->set_flat(false);
|
||||||
name_menu->set_text("..");
|
name_menu->set_text("..");
|
||||||
name_hbc->add_child(name_menu);
|
name_hbc->add_child(name_menu);
|
||||||
|
|
||||||
|
|||||||
@@ -825,6 +825,8 @@ void ColorPickerButton::_update_picker() {
|
|||||||
add_child(popup);
|
add_child(popup);
|
||||||
picker->connect("color_changed", this, "_color_changed");
|
picker->connect("color_changed", this, "_color_changed");
|
||||||
popup->connect("modal_closed", this, "_modal_closed");
|
popup->connect("modal_closed", this, "_modal_closed");
|
||||||
|
popup->connect("about_to_show", this, "set_pressed", varray(true));
|
||||||
|
popup->connect("popup_hide", this, "set_pressed", varray(false));
|
||||||
picker->set_pick_color(color);
|
picker->set_pick_color(color);
|
||||||
picker->set_edit_alpha(edit_alpha);
|
picker->set_edit_alpha(edit_alpha);
|
||||||
}
|
}
|
||||||
@@ -855,4 +857,6 @@ ColorPickerButton::ColorPickerButton() {
|
|||||||
picker = NULL;
|
picker = NULL;
|
||||||
popup = NULL;
|
popup = NULL;
|
||||||
edit_alpha = true;
|
edit_alpha = true;
|
||||||
|
|
||||||
|
set_toggle_mode(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,15 +116,19 @@ MenuButton::MenuButton() {
|
|||||||
|
|
||||||
switch_on_hover = false;
|
switch_on_hover = false;
|
||||||
set_flat(true);
|
set_flat(true);
|
||||||
|
set_toggle_mode(true);
|
||||||
set_disable_shortcuts(false);
|
set_disable_shortcuts(false);
|
||||||
set_enabled_focus_mode(FOCUS_NONE);
|
set_enabled_focus_mode(FOCUS_NONE);
|
||||||
|
set_process_unhandled_key_input(true);
|
||||||
|
set_action_mode(ACTION_MODE_BUTTON_PRESS);
|
||||||
|
|
||||||
popup = memnew(PopupMenu);
|
popup = memnew(PopupMenu);
|
||||||
popup->hide();
|
popup->hide();
|
||||||
add_child(popup);
|
add_child(popup);
|
||||||
popup->set_as_toplevel(true);
|
popup->set_as_toplevel(true);
|
||||||
popup->set_pass_on_modal_close_click(false);
|
popup->set_pass_on_modal_close_click(false);
|
||||||
set_process_unhandled_key_input(true);
|
popup->connect("about_to_show", this, "set_pressed", varray(true)); // For when switching from another MenuButton.
|
||||||
set_action_mode(ACTION_MODE_BUTTON_PRESS);
|
popup->connect("popup_hide", this, "set_pressed", varray(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuButton::~MenuButton() {
|
MenuButton::~MenuButton() {
|
||||||
|
|||||||
@@ -340,6 +340,7 @@ void OptionButton::_bind_methods() {
|
|||||||
OptionButton::OptionButton() {
|
OptionButton::OptionButton() {
|
||||||
|
|
||||||
current = -1;
|
current = -1;
|
||||||
|
set_toggle_mode(true);
|
||||||
set_text_align(ALIGN_LEFT);
|
set_text_align(ALIGN_LEFT);
|
||||||
set_action_mode(ACTION_MODE_BUTTON_PRESS);
|
set_action_mode(ACTION_MODE_BUTTON_PRESS);
|
||||||
|
|
||||||
@@ -350,6 +351,7 @@ OptionButton::OptionButton() {
|
|||||||
popup->set_pass_on_modal_close_click(false);
|
popup->set_pass_on_modal_close_click(false);
|
||||||
popup->connect("id_pressed", this, "_selected");
|
popup->connect("id_pressed", this, "_selected");
|
||||||
popup->connect("id_focused", this, "_focused");
|
popup->connect("id_focused", this, "_focused");
|
||||||
|
popup->connect("popup_hide", this, "set_pressed", varray(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionButton::~OptionButton() {
|
OptionButton::~OptionButton() {
|
||||||
|
|||||||
Reference in New Issue
Block a user