summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2020-03-07 18:02:54 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2020-03-26 16:24:05 +0100
commit15a9f94346c211b7afe96af500cb3405aabcf6b8 (patch)
tree150287a257a89a0ff579bcc81baa75a0bbca8c79 /scene/gui
parent197cb4e7718034aba35832a547477dfc858a7280 (diff)
Add macOS DisplayServer implementation.
Change global menu to use Callable, add support for check items and submenus.
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/line_edit.cpp21
-rw-r--r--scene/gui/text_edit.cpp20
2 files changed, 26 insertions, 15 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index fd82c33c4e..734e27b1b6 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -913,9 +913,10 @@ void LineEdit::_notification(int p_what) {
}
if (has_focus()) {
-
- DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
- DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + Point2(using_placeholder ? 0 : x_ofs, y_ofs + caret_height), get_viewport()->get_window_id());
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
+ DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + Point2(using_placeholder ? 0 : x_ofs, y_ofs + caret_height), get_viewport()->get_window_id());
+ }
}
} break;
case NOTIFICATION_FOCUS_ENTER: {
@@ -926,9 +927,11 @@ void LineEdit::_notification(int p_what) {
draw_caret = true;
}
- DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
- Point2 cursor_pos = Point2(get_cursor_position(), 1) * get_minimum_size().height;
- DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos, get_viewport()->get_window_id());
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
+ Point2 cursor_pos = Point2(get_cursor_position(), 1) * get_minimum_size().height;
+ DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos, get_viewport()->get_window_id());
+ }
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), max_length);
@@ -940,8 +943,10 @@ void LineEdit::_notification(int p_what) {
caret_blink_timer->stop();
}
- DisplayServer::get_singleton()->window_set_ime_position(Point2(), get_viewport()->get_window_id());
- DisplayServer::get_singleton()->window_set_ime_active(false, get_viewport()->get_window_id());
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_position(Point2(), get_viewport()->get_window_id());
+ DisplayServer::get_singleton()->window_set_ime_active(false, get_viewport()->get_window_id());
+ }
ime_text = "";
ime_selection = Point2();
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 49e89f6c6d..fb477ee3b4 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1754,8 +1754,10 @@ void TextEdit::_notification(int p_what) {
}
if (has_focus()) {
- DisplayServer::get_singleton()->window_set_ime_active(true);
- DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos + Point2(0, get_row_height()));
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
+ DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos + Point2(0, get_row_height()), get_viewport()->get_window_id());
+ }
}
} break;
case NOTIFICATION_FOCUS_ENTER: {
@@ -1766,9 +1768,11 @@ void TextEdit::_notification(int p_what) {
draw_caret = true;
}
- DisplayServer::get_singleton()->window_set_ime_active(true);
- Point2 cursor_pos = Point2(cursor_get_column(), cursor_get_line()) * get_row_height();
- DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos);
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
+ Point2 cursor_pos = Point2(cursor_get_column(), cursor_get_line()) * get_row_height();
+ DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos, get_viewport()->get_window_id());
+ }
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
DisplayServer::get_singleton()->virtual_keyboard_show(get_text(), get_global_rect());
@@ -1779,8 +1783,10 @@ void TextEdit::_notification(int p_what) {
caret_blink_timer->stop();
}
- DisplayServer::get_singleton()->window_set_ime_position(Point2());
- DisplayServer::get_singleton()->window_set_ime_active(false);
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_position(Point2(), get_viewport()->get_window_id());
+ DisplayServer::get_singleton()->window_set_ime_active(false, get_viewport()->get_window_id());
+ }
ime_text = "";
ime_selection = Point2();