mirror of
https://github.com/lihop/godot-xterm.git
synced 2024-11-22 17:50:25 +01:00
Prevent editor shortcuts while terminal is focused
This commit is contained in:
parent
bea5d1c27d
commit
6ec3c93c55
2 changed files with 21 additions and 12 deletions
|
@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Linux binaries now support systems with older GLIBC versions. By building the
|
- Linux binaries now support systems with older GLIBC versions. By building the
|
||||||
binaries inside a docker container with an older GLIBC version, the minimum
|
binaries inside a docker container with an older GLIBC version, the minimum
|
||||||
required GLIBC version is now 2.17 which was released in 2012.
|
required GLIBC version is now 2.17 which was released in 2012.
|
||||||
|
- Prevent all editor shortcuts while terminal is focused except for:
|
||||||
|
- The shortcuts used to switch between terminal tabs (Ctrl+Page up, Ctrl+Page down).
|
||||||
|
- Shortcuts starting with Ctrl + Shift. This includes the remaining default terminal
|
||||||
|
panel shortcuts such as 'Copy' (Ctrl+Shift+C) and 'New Terminal' (Ctrl+Shift+T).
|
||||||
- Target Godot version from 3.3.2-stable -> 3.4.4-stable.
|
- Target Godot version from 3.3.2-stable -> 3.4.4-stable.
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
|
@ -67,22 +67,27 @@ func _poll():
|
||||||
|
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
if not has_focus():
|
if has_focus() and event is InputEventKey and event.is_pressed():
|
||||||
|
if event.control and event.scancode in [KEY_PAGEUP, KEY_PAGEDOWN]:
|
||||||
|
# Handled by switch tabs shortcut.
|
||||||
return
|
return
|
||||||
|
|
||||||
# Ignore some input that is used by shortcuts.
|
if event.control and event.shift:
|
||||||
# TODO: Figure out how to handle this properly as the user might set their
|
# Not handled by terminal.
|
||||||
# own custom shortcuts.
|
|
||||||
if event is InputEventKey:
|
|
||||||
if event.shift:
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if event.control and event.scancode == KEY_PAGEUP or event.scancode == KEY_PAGEDOWN:
|
# Handle all other InputEventKey events to prevent triggering of editor
|
||||||
return
|
# shortcuts when using the terminal.
|
||||||
|
#
|
||||||
# We need to handle many input events otherwise keys such as TAB, ctrl, etc.
|
# Currently the only way to get shortcuts is by calling editor_settings.get_setting("shortcuts")
|
||||||
# will trigger editor shortcuts when using them in the terminal.
|
# and it returns an array that *only* contains shortcuts that have been modified from the original.
|
||||||
if event is InputEventKey:
|
# Once https://github.com/godotengine/godot-proposals/issues/4112 is resolved it should be possible
|
||||||
|
# to get all shortcuts by their editor setting string as documented here:
|
||||||
|
# https://docs.godotengine.org/en/stable/tutorials/editor/default_key_mapping.html.
|
||||||
|
# In this case we could simply add a setting called something like "allowed shortcuts" or
|
||||||
|
# "propagated shortcuts" consisting of an array of shortcut editor setting strings.
|
||||||
|
# For example "editor/save_scene" which saves the scene and by default maps to 'Ctrl + S'.
|
||||||
|
# Then any shortcut events listed here can be handled by the terminal *and* the editor.
|
||||||
get_tree().set_input_as_handled()
|
get_tree().set_input_as_handled()
|
||||||
_gui_input(event)
|
_gui_input(event)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue