Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

ctrlKey toggles the hint list #8504

Closed
wants to merge 3 commits into from

5 participants

@ramsundhar20

Fix for bug #8142. Control key toggles the hint list.

ramsundhar20 added some commits
@ramsundhar20 ramsundhar20 #8142 ctrlKey toggles the hint list
Fix for bug #8142. Control key toggles the hint list.
5415c63
@ramsundhar20 ramsundhar20 Revert "#8142 ctrlKey toggles the hint list"
This reverts commit 5415c63693acf7f10c29ccabd93fdf94ea2b86f5.
47de57b
@ramsundhar20 ramsundhar20 Revert "Revert "#8142 ctrlKey toggles the hint list""
This reverts commit 47de57b32e09b73aff44514b360fd74e63ecee6f.
c92e894
@peterflynn
Owner

@ramsundhar20 Hmm, moving the highlight when you press Ctrl alone seems a little weird. It's very uncommon for modifier keys to cause any action on their own. Do you have an example of another editor that does this?

Also, make sure this doesn't break shortcut key handling. On Windows & Mac shortcuts are normally handled natively, but you can patch Globals.js to force brackets.nativeMenus to false in order to test JS-driven shortcut key handling. Are you still able to invoke commands like Ctrl+S or Ctrl+W while the code hints popup is open? And can you move the cursor in whole-word increments using Ctrl+Left/Right?

@ramsundhar20

Thank you for your inputs. I will check the key combinations you suggested. I had a issue when implementing the actual requirement. I wasn't getting the space keycode when Ctrl was pressed. I was getting a keycode of 17 instead of 32. I thought it would be comfortable to toggle hints with just a single key, when the hint is open.

@RaymondLim
Collaborator

@ramsundhar20 You cannot check keyCode === KeyEvent.DOM_VK_CONTROL to capture the Ctrl/Cmd+Space keydown combination. What you're getting is a single keydown on Ctrl key. The correct way to check for the combination is to check event.ctrlKey and keyCode === KeyEvent.DOM_VK_SPACE.

@ramsundhar20

@RaymondLim please find my earlier comments in the bug.I have proposed the same solution. I am not getting the keycode 32(space) when Ctrl key is pressed. Please suggest a alternative method

@RaymondLim
Collaborator

@ramsundhar20 You don't get space key because you're not updating the list of allowed keys in CodeHintList.prototype.isHandlingKeyCode by adding KeyEvent.DOM_VK_SPACE. Once you do that, then you should be able to check the key combination correct way.

@ramsundhar20

@RaymondLim I tried that also. I will verify it once again.

@RaymondLim
Collaborator

@ramsundhar20 You're right! After all, Ctrl+Space is already used as a shortcut to invoke the code hints and you won't be getting the combination as a keydown event. So we can't use the same key combination as described in #8142.

@ramsundhar20

Any idea, how this can be implemented? How about hint list toggling on just space key instead of ctrl key?

It would void issues as @peterflynn said, if they persist.

@RaymondLim
Collaborator

If we want to implement this, then we need to modify the code in _startNewSession() in CodeHintManager.js file by not calling _endSession() and instead call our new code to move down the selection in CodeHintList.js.

@ramsundhar20

I will look into those sections and come back with a better fix.

@ramsundhar20

I just checked the suggestions said by @peterflynn . It seems to work fine and doesn't break any functionality. I feel ctrl toggle is a cool feature to have. Its very handy, may be you can try this feature in your local code base.

@RaymondLim RaymondLim was assigned by redmunds
@redmunds
Collaborator

Assigning to @RaymondLim who is triaging this PR.

@RaymondLim
Collaborator

@ramsundhar20 I don't think @peterflynn was approving the ctrl key as the right (or acceptable) shortcut. Since it does not fit to the request in #8142, we will not take this solution. You're welcome to work on a new solution as I mentioned in the above comment.

@peterflynn
Owner

Yes, I think we should close this -- having Ctrl alone take any action is very unusual, and absent any precedent set by others editors doing that, I don't think we should do it either.

We can still take a fix for #8142 if it uses Ctrl+Space or some other standard shortcut, but it's probably best to do it atop a new, clean pull request.

@ramsundhar20 Sound ok?

@JeffryBooher
Collaborator

I'm adding the triage complete label since we don't want to take this pr.

@peterflynn
Owner

@JeffryBooher Normally, adding that label means we do want to take the PR. So I'll close it instead. (@ramsundhar20, feel free to open a new PR with a better shortcut if you want).

@peterflynn peterflynn closed this
@ramsundhar20

Sounds good. Am working on the fix. I will post a separate pull request after the fix is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 22, 2014
  1. @ramsundhar20

    #8142 ctrlKey toggles the hint list

    ramsundhar20 authored
    Fix for bug #8142. Control key toggles the hint list.
  2. @ramsundhar20

    Revert "#8142 ctrlKey toggles the hint list"

    ramsundhar20 authored
    This reverts commit 5415c63693acf7f10c29ccabd93fdf94ea2b86f5.
  3. @ramsundhar20

    Revert "Revert "#8142 ctrlKey toggles the hint list""

    ramsundhar20 authored
    This reverts commit 47de57b32e09b73aff44514b360fd74e63ecee6f.
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 5 deletions.
  1. +4 −5 src/editor/CodeHintList.js
View
9 src/editor/CodeHintList.js
@@ -310,13 +310,13 @@ define(function (require, exports, module) {
CodeHintList.prototype.isHandlingKeyCode = function (keyCode) {
return (keyCode === KeyEvent.DOM_VK_UP || keyCode === KeyEvent.DOM_VK_DOWN ||
keyCode === KeyEvent.DOM_VK_PAGE_UP || keyCode === KeyEvent.DOM_VK_PAGE_DOWN ||
- keyCode === KeyEvent.DOM_VK_RETURN ||
+ keyCode === KeyEvent.DOM_VK_RETURN || keyCode === KeyEvent.DOM_VK_CONTROL ||
(keyCode === KeyEvent.DOM_VK_TAB && this.insertHintOnTab));
};
/**
* Convert keydown events into hint list navigation actions.
- *
+ * Also ctrlKey toggles the list selection
* @param {KeyBoardEvent} keyEvent
*/
CodeHintList.prototype._keydownHook = function (event) {
@@ -383,19 +383,18 @@ define(function (require, exports, module) {
// (page) up, (page) down, enter and tab key are handled by the list
if (event.type === "keydown" && this.isHandlingKeyCode(event.keyCode)) {
keyCode = event.keyCode;
-
if (event.shiftKey &&
(event.keyCode === KeyEvent.DOM_VK_UP ||
event.keyCode === KeyEvent.DOM_VK_DOWN ||
event.keyCode === KeyEvent.DOM_VK_PAGE_UP ||
event.keyCode === KeyEvent.DOM_VK_PAGE_DOWN)) {
this.handleClose();
-
+
// Let the event bubble.
return false;
} else if (keyCode === KeyEvent.DOM_VK_UP) {
_rotateSelection.call(this, -1);
- } else if (keyCode === KeyEvent.DOM_VK_DOWN) {
+ } else if ((keyCode === KeyEvent.DOM_VK_DOWN)||(event.ctrlKey)) {
_rotateSelection.call(this, 1);
} else if (keyCode === KeyEvent.DOM_VK_PAGE_UP) {
_rotateSelection.call(this, -_itemsPerPage());
Something went wrong with that request. Please try again.