You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-26 15:46:23 +00:00
Add drag and drop option for line edit and rich text label
This commit is contained in:
@@ -341,13 +341,15 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) {
|
||||
}
|
||||
|
||||
selection.drag_attempt = false;
|
||||
|
||||
if ((caret_column < selection.begin) || (caret_column > selection.end) || !selection.enabled) {
|
||||
deselect();
|
||||
selection.start_column = caret_column;
|
||||
selection.creating = true;
|
||||
} else if (selection.enabled && !selection.double_click) {
|
||||
selection.drag_attempt = true;
|
||||
if (!selection.double_click) {
|
||||
bool is_inside_sel = selection.enabled && caret_column >= selection.begin && caret_column <= selection.end;
|
||||
if (drag_and_drop_selection_enabled && is_inside_sel) {
|
||||
selection.drag_attempt = true;
|
||||
} else {
|
||||
deselect();
|
||||
selection.start_column = caret_column;
|
||||
selection.creating = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2224,6 +2226,14 @@ bool LineEdit::is_deselect_on_focus_loss_enabled() const {
|
||||
return deselect_on_focus_loss_enabled;
|
||||
}
|
||||
|
||||
void LineEdit::set_drag_and_drop_selection_enabled(const bool p_enabled) {
|
||||
drag_and_drop_selection_enabled = p_enabled;
|
||||
}
|
||||
|
||||
bool LineEdit::is_drag_and_drop_selection_enabled() const {
|
||||
return drag_and_drop_selection_enabled;
|
||||
}
|
||||
|
||||
void LineEdit::set_right_icon(const Ref<Texture2D> &p_icon) {
|
||||
if (right_icon == p_icon) {
|
||||
return;
|
||||
@@ -2570,6 +2580,8 @@ void LineEdit::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("is_selecting_enabled"), &LineEdit::is_selecting_enabled);
|
||||
ClassDB::bind_method(D_METHOD("set_deselect_on_focus_loss_enabled", "enable"), &LineEdit::set_deselect_on_focus_loss_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_deselect_on_focus_loss_enabled"), &LineEdit::is_deselect_on_focus_loss_enabled);
|
||||
ClassDB::bind_method(D_METHOD("set_drag_and_drop_selection_enabled", "enable"), &LineEdit::set_drag_and_drop_selection_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_drag_and_drop_selection_enabled"), &LineEdit::is_drag_and_drop_selection_enabled);
|
||||
ClassDB::bind_method(D_METHOD("set_right_icon", "icon"), &LineEdit::set_right_icon);
|
||||
ClassDB::bind_method(D_METHOD("get_right_icon"), &LineEdit::get_right_icon);
|
||||
ClassDB::bind_method(D_METHOD("set_flat", "enabled"), &LineEdit::set_flat);
|
||||
@@ -2638,6 +2650,7 @@ void LineEdit::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "middle_mouse_paste_enabled"), "set_middle_mouse_paste_enabled", "is_middle_mouse_paste_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "selecting_enabled"), "set_selecting_enabled", "is_selecting_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "deselect_on_focus_loss_enabled"), "set_deselect_on_focus_loss_enabled", "is_deselect_on_focus_loss_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "drag_and_drop_selection_enabled"), "set_drag_and_drop_selection_enabled", "is_drag_and_drop_selection_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "right_icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_right_icon", "get_right_icon");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flat"), "set_flat", "is_flat");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_control_chars"), "set_draw_control_chars", "get_draw_control_chars");
|
||||
|
||||
Reference in New Issue
Block a user