mirror of https://github.com/zulip/zulip.git
Tweak hotkey behavior when pointer isn't shown.
Disable the hotkeys that act on the current message, except Enter immediately shows the cursor without moving it. (imported from commit 74fb298c711e61ae98c210d0ed11c875ce6ba591)
This commit is contained in:
parent
0cd90cbe4a
commit
b06c2f7ccf
|
@ -212,18 +212,10 @@ function process_hotkey(e) {
|
|||
}
|
||||
|
||||
switch (event_name) {
|
||||
case 'narrow_by_recipient':
|
||||
return do_narrow_action(narrow.by_recipient);
|
||||
case 'narrow_by_subject':
|
||||
return do_narrow_action(narrow.by_subject);
|
||||
case 'narrow_private':
|
||||
return do_narrow_action(function (target, opts) {
|
||||
narrow.by('is', 'private-message', opts);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
switch (event_name) {
|
||||
case 'page_up':
|
||||
if (viewport.at_top() && !current_msg_list.empty()) {
|
||||
current_msg_list.select_id(current_msg_list.first().id, {then_scroll: false});
|
||||
|
@ -257,17 +249,6 @@ function process_hotkey(e) {
|
|||
compose.set_mode('private');
|
||||
respond_to_sent_message = true;
|
||||
return true;
|
||||
case 'enter': // Enter: respond to message (unless we need to do something else)
|
||||
respond_to_cursor = true;
|
||||
respond_to_message({trigger: 'hotkey enter'});
|
||||
return true;
|
||||
case 'reply_message': // 'r': respond to message
|
||||
respond_to_cursor = true;
|
||||
respond_to_message({trigger: 'hotkey'});
|
||||
return true;
|
||||
case 'respond_to_author': // 'R': respond to author
|
||||
respond_to_message({reply_type: "personal", trigger: 'hotkey pm'});
|
||||
return true;
|
||||
case 'search':
|
||||
search.initiate_search();
|
||||
return true;
|
||||
|
@ -276,6 +257,36 @@ function process_hotkey(e) {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (ui.pointer_visible()) {
|
||||
// These actions act on the message under the pointer and don't make
|
||||
// sense when the pointer is hidden.
|
||||
switch (event_name) {
|
||||
case 'narrow_by_recipient':
|
||||
return do_narrow_action(narrow.by_recipient);
|
||||
case 'narrow_by_subject':
|
||||
return do_narrow_action(narrow.by_subject);
|
||||
case 'enter': // Enter: respond to message (unless we need to do something else)
|
||||
respond_to_cursor = true;
|
||||
respond_to_message({trigger: 'hotkey enter'});
|
||||
return true;
|
||||
case 'reply_message': // 'r': respond to message
|
||||
respond_to_cursor = true;
|
||||
respond_to_message({trigger: 'hotkey'});
|
||||
return true;
|
||||
case 'respond_to_author': // 'R': respond to author
|
||||
respond_to_message({reply_type: "personal", trigger: 'hotkey pm'});
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// Behavior when cursor is hidden
|
||||
switch (event_name) {
|
||||
case 'enter':
|
||||
ui.show_pointer(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -720,8 +720,17 @@ exports.stream_sidebar_currently_popped = function () {
|
|||
return current_stream_sidebar_elem !== undefined;
|
||||
};
|
||||
|
||||
exports.show_pointer = function () {
|
||||
exports.show_pointer = function (apply_now) {
|
||||
pointer_visible = true;
|
||||
if (apply_now) {
|
||||
// Needs a selection change to actually apply the class. Otherwise the
|
||||
// next selection change makes the cursor visible.
|
||||
current_msg_list.select_id(current_msg_list.selected_id());
|
||||
}
|
||||
};
|
||||
|
||||
exports.pointer_visible = function () {
|
||||
return pointer_visible;
|
||||
};
|
||||
|
||||
$(function () {
|
||||
|
|
Loading…
Reference in New Issue