@@ -419,7 +419,7 @@ void ViewportRotationControl::_process_click(int p_index, Vector2 p_position, bo
419
419
orbiting_index = p_index;
420
420
}
421
421
} else {
422
- if (focused_axis > -1 ) {
422
+ if (focused_axis > -1 && gizmo_activated ) {
423
423
viewport->_menu_option (axis_menu_options[focused_axis]);
424
424
_update_focus ();
425
425
}
@@ -432,10 +432,11 @@ void ViewportRotationControl::_process_click(int p_index, Vector2 p_position, bo
432
432
}
433
433
434
434
void ViewportRotationControl::_process_drag (Ref<InputEventWithModifiers> p_event, int p_index, Vector2 p_position, Vector2 p_relative_position) {
435
- if (orbiting_index == p_index) {
435
+ if (orbiting_index == p_index && gizmo_activated ) {
436
436
if (Input::get_singleton ()->get_mouse_mode () == Input::MOUSE_MODE_VISIBLE) {
437
437
Input::get_singleton ()->set_mouse_mode (Input::MOUSE_MODE_CAPTURED);
438
438
orbiting_mouse_start = p_position;
439
+ viewport->previous_cursor = viewport->cursor ;
439
440
}
440
441
viewport->_nav_orbit (p_event, p_relative_position);
441
442
focused_axis = -1 ;
@@ -447,10 +448,35 @@ void ViewportRotationControl::_process_drag(Ref<InputEventWithModifiers> p_event
447
448
void ViewportRotationControl::gui_input (const Ref<InputEvent> &p_event) {
448
449
ERR_FAIL_COND (p_event.is_null ());
449
450
451
+ // Key events
452
+ const Ref<InputEventKey> k = p_event;
453
+
454
+ if (k.is_valid () && k->is_action_pressed (SNAME (" ui_cancel" ), false , true )) {
455
+ if (Input::get_singleton ()->get_mouse_mode () == Input::MOUSE_MODE_CAPTURED) {
456
+ Input::get_singleton ()->set_mouse_mode (Input::MOUSE_MODE_VISIBLE);
457
+ Input::get_singleton ()->warp_mouse (orbiting_mouse_start);
458
+ viewport->cursor = viewport->previous_cursor ;
459
+ gizmo_activated = false ;
460
+ }
461
+ }
462
+
450
463
// Mouse events
451
464
const Ref<InputEventMouseButton> mb = p_event;
452
- if (mb.is_valid () && mb->get_button_index () == MouseButton::LEFT) {
453
- _process_click (100 , mb->get_position (), mb->is_pressed ());
465
+ if (mb.is_valid ()) {
466
+ if (mb->get_button_index () == MouseButton::LEFT) {
467
+ _process_click (100 , mb->get_position (), mb->is_pressed ());
468
+ if (mb->is_pressed ()) {
469
+ gizmo_activated = true ;
470
+ grab_focus ();
471
+ }
472
+ } else if (mb->get_button_index () == MouseButton::RIGHT) {
473
+ if (Input::get_singleton ()->get_mouse_mode () == Input::MOUSE_MODE_CAPTURED) {
474
+ Input::get_singleton ()->set_mouse_mode (Input::MOUSE_MODE_VISIBLE);
475
+ Input::get_singleton ()->warp_mouse (orbiting_mouse_start);
476
+ viewport->cursor = viewport->previous_cursor ;
477
+ gizmo_activated = false ;
478
+ }
479
+ }
454
480
}
455
481
456
482
const Ref<InputEventMouseMotion> mm = p_event;
@@ -3325,7 +3351,7 @@ void Node3DEditorViewport::_draw() {
3325
3351
force_over_plugin_list->forward_3d_force_draw_over_viewport (surface);
3326
3352
}
3327
3353
3328
- if (surface->has_focus ()) {
3354
+ if (surface->has_focus () || rotation_control-> has_focus () ) {
3329
3355
Size2 size = surface->get_size ();
3330
3356
Rect2 r = Rect2 (Point2 (), size);
3331
3357
get_theme_stylebox (SNAME (" FocusViewport" ), EditorStringName (EditorStyles))->draw (surface->get_canvas_item (), r);
@@ -5778,6 +5804,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p
5778
5804
rotation_control->set_custom_minimum_size (Size2 (80 , 80 ) * EDSCALE);
5779
5805
rotation_control->set_h_size_flags (SIZE_SHRINK_END);
5780
5806
rotation_control->set_viewport (this );
5807
+ rotation_control->set_focus_mode (FOCUS_CLICK);
5781
5808
top_right_vbox->add_child (rotation_control);
5782
5809
5783
5810
frame_time_panel = memnew (PanelContainer);
0 commit comments