summaryrefslogtreecommitdiff
path: root/scene/gui/line_edit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/line_edit.cpp')
-rw-r--r--scene/gui/line_edit.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index bc579020bd..f4dd3e92cd 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -574,8 +574,12 @@ void LineEdit::_notification(int p_what) {
RID ci = get_canvas_item();
Ref<StyleBox> style = get_stylebox("normal");
- if (!is_editable())
+ float disabled_alpha = 1.0; // used to set the disabled input text color
+ if (!is_editable()) {
style = get_stylebox("read_only");
+ disabled_alpha = .5;
+ draw_caret = false;
+ }
Ref<Font> font = get_font("font");
@@ -622,6 +626,13 @@ void LineEdit::_notification(int p_what) {
// draw placeholder color
if (text.empty())
font_color.a *= placeholder_alpha;
+ font_color.a *= disabled_alpha;
+
+ if (has_icon("right_icon")) {
+ Ref<Texture> r_icon = Control::get_icon("right_icon");
+ ofs_max -= r_icon->get_width();
+ r_icon->draw(ci, Point2(width - r_icon->get_width() - x_ofs, y_ofs), Color(1, 1, 1, disabled_alpha * .9));
+ }
int caret_height = font->get_height() > y_area ? y_area : font->get_height();
while (true) {
@@ -660,6 +671,11 @@ void LineEdit::_notification(int p_what) {
Point2(x_ofs, y_ofs), Size2(1, caret_height)),
cursor_color);
}
+
+ if (has_focus()) {
+
+ OS::get_singleton()->set_ime_position(get_global_position() + Point2(x_ofs, y_ofs + caret_height));
+ }
} break;
case NOTIFICATION_FOCUS_ENTER: {
@@ -667,12 +683,17 @@ void LineEdit::_notification(int p_what) {
draw_caret = true;
}
+ Point2 cursor_pos = Point2(get_cursor_pos(), 1) * get_minimum_size().height;
+ OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos);
+
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->show_virtual_keyboard(text, get_global_rect());
} break;
case NOTIFICATION_FOCUS_EXIT: {
+ OS::get_singleton()->set_ime_position(Point2());
+
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->hide_virtual_keyboard();
@@ -1181,7 +1202,9 @@ void LineEdit::menu_option(int p_option) {
select_all();
} break;
case MENU_UNDO: {
- undo();
+ if (editable) {
+ undo();
+ }
} break;
}
}