Add shortcut_cell double click functionality
This commit is contained in:
parent
df1724470d
commit
8acc8838c4
|
@ -513,6 +513,38 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column
|
|||
}
|
||||
}
|
||||
|
||||
void EditorSettingsDialog::_shortcut_cell_double_clicked() {
|
||||
// When a shortcut cell is double clicked:
|
||||
// If the cell has children and is in the bindings column, and if its first child is editable,
|
||||
// then uncollapse the cell, and if the first child is the only child, then edit that child.
|
||||
// If the cell is in the bindings column and can be edited, then edit it.
|
||||
// If the cell is in the name column, then toggle collapse.
|
||||
const ShortcutButton edit_btn_id = EditorSettingsDialog::SHORTCUT_EDIT;
|
||||
const int edit_btn_col = 1;
|
||||
TreeItem *ti = shortcuts->get_selected();
|
||||
String type = ti->get_meta("type");
|
||||
int col = shortcuts->get_selected_column();
|
||||
if (type == "shortcut" && col == 0) {
|
||||
if (ti->get_first_child()) {
|
||||
ti->set_collapsed(!ti->is_collapsed());
|
||||
}
|
||||
} else if (type == "shortcut" && col == 1) {
|
||||
if (ti->get_first_child()) {
|
||||
TreeItem *child_ti = ti->get_first_child();
|
||||
if (child_ti->get_button_by_id(edit_btn_col, edit_btn_id) != -1) {
|
||||
ti->set_collapsed(false);
|
||||
if (ti->get_child_count() == 1) {
|
||||
_shortcut_button_pressed(child_ti, edit_btn_col, edit_btn_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (type == "event" && col == 1) {
|
||||
if (ti->get_button_by_id(edit_btn_col, edit_btn_id) != -1) {
|
||||
_shortcut_button_pressed(ti, edit_btn_col, edit_btn_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Variant EditorSettingsDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
|
||||
TreeItem *selected = shortcuts->get_selected();
|
||||
|
||||
|
@ -692,6 +724,7 @@ EditorSettingsDialog::EditorSettingsDialog() {
|
|||
shortcuts->set_column_title(0, TTR("Name"));
|
||||
shortcuts->set_column_title(1, TTR("Binding"));
|
||||
shortcuts->connect("button_pressed", callable_mp(this, &EditorSettingsDialog::_shortcut_button_pressed));
|
||||
shortcuts->connect("item_activated", callable_mp(this, &EditorSettingsDialog::_shortcut_cell_double_clicked));
|
||||
tab_shortcuts->add_child(shortcuts);
|
||||
|
||||
shortcuts->set_drag_forwarding(this);
|
||||
|
|
|
@ -104,6 +104,7 @@ class EditorSettingsDialog : public AcceptDialog {
|
|||
|
||||
void _update_shortcuts();
|
||||
void _shortcut_button_pressed(Object *p_item, int p_column, int p_idx);
|
||||
void _shortcut_cell_double_clicked();
|
||||
|
||||
void _builtin_action_popup_index_pressed(int p_index);
|
||||
|
||||
|
|
|
@ -2490,7 +2490,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int
|
|||
/* process selection */
|
||||
|
||||
if (p_double_click && (!c.editable || c.mode == TreeItem::CELL_MODE_CUSTOM || c.mode == TreeItem::CELL_MODE_ICON /*|| c.mode==TreeItem::CELL_MODE_CHECK*/)) { //it's confusing for check
|
||||
|
||||
// Emits the "item_activated" signal.
|
||||
propagate_mouse_activated = true;
|
||||
|
||||
incr_search.clear();
|
||||
|
|
Loading…
Reference in New Issue