Browse Source

Display arrow cursor if text is not editable

(cherry picked from commit c3967c80abd2078f0996761faed256a33cf38d97)
kobewi 4 năm trước cách đây
mục cha
commit
cb5870dd4a
2 tập tin đã thay đổi với 4 bổ sung3 xóa
  1. 1 1
      scene/gui/line_edit.cpp
  2. 3 2
      scene/gui/text_edit.cpp

+ 1 - 1
scene/gui/line_edit.cpp

@@ -648,7 +648,7 @@ void LineEdit::drop_data(const Point2 &p_point, const Variant &p_data) {
 }
 
 Control::CursorShape LineEdit::get_cursor_shape(const Point2 &p_pos) const {
-	if (!text.empty() && is_editable() && _is_over_clear_button(p_pos)) {
+	if ((!text.empty() && is_editable() && _is_over_clear_button(p_pos)) || (!is_editable() && (!is_selecting_enabled() || text.empty()))) {
 		return CURSOR_ARROW;
 	}
 	return Control::get_cursor_shape(p_pos);

+ 3 - 2
scene/gui/text_edit.cpp

@@ -4811,10 +4811,11 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const {
 		return CURSOR_POINTING_HAND;
 	}
 
-	int gutter = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width;
-	if ((completion_active && completion_rect.has_point(p_pos))) {
+	if ((completion_active && completion_rect.has_point(p_pos)) || (is_readonly() && (!is_selecting_enabled() || text.size() == 0))) {
 		return CURSOR_ARROW;
 	}
+
+	int gutter = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width;
 	if (p_pos.x < gutter) {
 		int row, col;
 		_get_mouse_pos(p_pos, row, col);