mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1743339 - Make NativeKeyBindings
for single line editor try the one for multiline editor too r=stransky
`GtkEntry` is used to check what editing or natvigation command is mapped to every key combination when `<input>` has focus. However, it does not support `select-all` signal, thus, Gecko does not respect native shortcut key for "Select All". This patch makes it try to check whether the given key combination is mapped to "Select All" or not in `GtkTextView` widget which supports `select-all` signal. Thus, we'll get consistent behavior between `<input>` and `<textarea>` about "Select All". Differential Revision: https://phabricator.services.mozilla.com/D132450
This commit is contained in:
parent
571e82c9f0
commit
e70edff6bc
@ -11582,6 +11582,19 @@
|
||||
#endif
|
||||
mirror: always
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
# Only GtkTextView (native multiline text viewer/editor) supports "select-all"
|
||||
# signal so that we cannot know "select-all" key bindings only with GtkEntry.
|
||||
# When this pref is set to true, if a key combination does not cause any
|
||||
# signals in GtkEntry, try to check the key combination is mapped to
|
||||
# "select-all" in GtkTextView or not. If it's mapped to other commands, they
|
||||
# are just ignored.
|
||||
- name: ui.key.use_select_all_in_single_line_editor
|
||||
type: bool
|
||||
value: @IS_NIGHTLY_BUILD@
|
||||
mirror: always
|
||||
#endif
|
||||
|
||||
# Duration of timeout of incremental search in menus (ms). 0 means infinite.
|
||||
- name: ui.menu.incremental_search.timeout
|
||||
type: uint32_t
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/StaticPrefs_ui.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "mozilla/WritingModes.h"
|
||||
|
||||
@ -334,6 +335,23 @@ void NativeKeyBindings::GetEditCommands(const WidgetKeyboardEvent& aEvent,
|
||||
}
|
||||
}
|
||||
|
||||
// If the key event does not cause any commands, and we're for single line
|
||||
// editor, let's check whether the key combination is for "select-all" in
|
||||
// GtkTextView because the signal is not supported by GtkEntry.
|
||||
if (aCommands.IsEmpty() && this == sInstanceForSingleLineEditor &&
|
||||
StaticPrefs::ui_key_use_select_all_in_single_line_editor()) {
|
||||
if (NativeKeyBindings* bindingsForMultilineEditor =
|
||||
GetInstance(nsIWidget::NativeKeyBindingsForMultiLineEditor)) {
|
||||
bindingsForMultilineEditor->GetEditCommands(aEvent, aWritingMode,
|
||||
aCommands);
|
||||
if (aCommands.Length() == 1u &&
|
||||
aCommands[0u] == static_cast<CommandInt>(Command::SelectAll)) {
|
||||
return;
|
||||
}
|
||||
aCommands.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
gtk_bindings_activate_event is preferable, but it has unresolved bug:
|
||||
http://bugzilla.gnome.org/show_bug.cgi?id=162726
|
||||
|
Loading…
Reference in New Issue
Block a user