summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorŁukasz Rutkowski <lukus178@gmail.com>2018-08-11 12:04:19 +0200
committerŁukasz Rutkowski <lukus178@gmail.com>2018-08-11 12:04:26 +0200
commit81fb81de9d9fe7ae075bd06a3877d6cb452af67f (patch)
treef753bd70228e21956d681d814acb9cfa687f150e /scene/gui
parente8a435c8cdc5778ebae5e66d983a7bc720f81e85 (diff)
Do not use theme to set LineEdit right_icon
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/line_edit.cpp17
-rw-r--r--scene/gui/line_edit.h4
2 files changed, 16 insertions, 5 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index e723262c85..549daecdae 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -700,8 +700,8 @@ void LineEdit::_notification(int p_what) {
font_color.a *= disabled_alpha;
bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled;
- if (has_icon("right_icon") || display_clear_icon) {
- Ref<Texture> r_icon = Control::get_icon(display_clear_icon ? "clear" : "right_icon");
+ if (right_icon.is_valid() || display_clear_icon) {
+ Ref<Texture> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon;
Color color_icon(1, 1, 1, disabled_alpha * .9);
if (display_clear_icon) {
if (clear_button_status.press_attempt && clear_button_status.pressing_inside) {
@@ -1154,9 +1154,8 @@ void LineEdit::set_cursor_position(int p_pos) {
} else if (cursor_pos > window_pos) {
/* Adjust window if cursor goes too much to the right */
int window_width = get_size().width - style->get_minimum_size().width;
- if (has_icon("right_icon")) {
- Ref<Texture> r_icon = Control::get_icon("right_icon");
- window_width -= r_icon->get_width();
+ if (right_icon.is_valid()) {
+ window_width -= right_icon->get_width();
}
if (window_width < 0)
@@ -1455,6 +1454,14 @@ bool LineEdit::is_clear_button_enabled() const {
return clear_button_enabled;
}
+void LineEdit::set_right_icon(const Ref<Texture> &p_icon) {
+ if (right_icon == p_icon) {
+ return;
+ }
+ right_icon = p_icon;
+ update();
+}
+
void LineEdit::_ime_text_callback(void *p_self, String p_text, Point2 p_selection) {
LineEdit *self = (LineEdit *)p_self;
self->ime_text = p_text;
diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h
index d3cdb41903..5294d99da0 100644
--- a/scene/gui/line_edit.h
+++ b/scene/gui/line_edit.h
@@ -89,6 +89,8 @@ private:
bool clear_button_enabled;
+ Ref<Texture> right_icon;
+
struct Selection {
int begin;
@@ -215,6 +217,8 @@ public:
void set_clear_button_enabled(bool p_enabled);
bool is_clear_button_enabled() const;
+ void set_right_icon(const Ref<Texture> &p_icon);
+
virtual bool is_text_field() const;
LineEdit();
~LineEdit();