@@ -120,6 +120,11 @@ View3DController::NavigationMode View3DController::_get_nav_mode_from_shortcuts(
120120bool View3DController::gui_input (const Ref<InputEvent> &p_event, const Rect2 &p_surface_rect) {
121121 Ref<InputEventMouseButton> b = p_event;
122122 if (b.is_valid ()) {
123+ if (b->get_button_index () == MouseButton::RIGHT && b->is_pressed () && navigating) {
124+ cancel_navigation ();
125+ return true ;
126+ }
127+
123128 const real_t zoom_factor = 1 + (ZOOM_FREELOOK_MULTIPLIER - 1 ) * b->get_factor ();
124129 switch (b->get_button_index ()) {
125130 case MouseButton::WHEEL_UP: {
@@ -168,6 +173,18 @@ bool View3DController::gui_input(const Ref<InputEvent> &p_event, const Rect2 &p_
168173
169174 Ref<InputEventMouseMotion> m = p_event;
170175 if (m.is_valid ()) {
176+ if (m->get_button_mask () == MouseButtonMask::NONE) {
177+ navigation_cancelled = false ;
178+ }
179+
180+ if (navigation_cancelled) {
181+ return false ;
182+ }
183+
184+ if (!navigating) {
185+ previous_cursor = cursor;
186+ }
187+
171188 NavigationMode nav_mode = NAV_MODE_NONE;
172189
173190 if (m->get_button_mask ().has_flag (MouseButtonMask::LEFT)) {
@@ -229,10 +246,14 @@ bool View3DController::gui_input(const Ref<InputEvent> &p_event, const Rect2 &p_
229246 } break ;
230247
231248 default : {
249+ navigating = false ;
232250 return false ;
233251 }
234252 }
235253
254+ if (!freelook) {
255+ navigating = true ;
256+ }
236257 return true ;
237258 }
238259
@@ -283,6 +304,12 @@ bool View3DController::gui_input(const Ref<InputEvent> &p_event, const Rect2 &p_
283304 return true ;
284305 }
285306
307+ Ref<InputEventKey> k = p_event;
308+ if (k.is_valid () && k->is_pressed () && !k->is_echo () && k->get_keycode () == Key::ESCAPE && navigating) {
309+ cancel_navigation ();
310+ return true ;
311+ }
312+
286313 bool pressed = false ;
287314 float old_fov_scale = cursor.fov_scale ;
288315
@@ -306,6 +333,12 @@ bool View3DController::gui_input(const Ref<InputEvent> &p_event, const Rect2 &p_
306333 return pressed;
307334}
308335
336+ void View3DController::cancel_navigation () {
337+ navigating = false ;
338+ navigation_cancelled = true ;
339+ cursor = previous_cursor;
340+ }
341+
309342void View3DController::cursor_pan (const Ref<InputEventWithModifiers> &p_event, const Vector2 &p_relative) {
310343 float pan_speed = translation_sensitivity / 150.0 ;
311344 if (p_event.is_valid () && navigation_scheme == NAV_SCHEME_MAYA && p_event->is_shift_pressed ()) {
0 commit comments