Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 347875

Summary: [editor] editor never propagates a key if a keybinding is registered, even if function returns false
Product: [ECD] Orion Reporter: Susan McCourt <susan>
Component: ClientAssignee: Felipe Heidrich <eclipse.felipe>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.felipe, Silenio_Quarti
Version: 0.2   
Target Milestone: 0.2   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Susan McCourt CLA 2011-05-31 19:52:24 EDT
I was assuming that if I returned false out of an action's function, the editor would let the key event propagate.

But it appears that this return value is only used to decide if a default handler should be run.  editor._doAction always returns true if a binding was registered, even if no one did anything.

My case is the Esc key.  We bind the Esc key to cancel any active modes in the editor.  If there is no active mode, I return false from my action function.  Outside the editor, we hook Esc to dismiss the "Show Keys" panel if it's active.  But since the Esc key never propagates out of the editor, we never get the Esc.  This makes it very difficult to dismiss the Show Keys panel (Ctrl+Shift+?).  

I think that editor._doAction should return false if the function returned false and no default handler was run.
Comment 1 Susan McCourt CLA 2011-06-07 15:16:58 EDT
Felipe, could you look at this for RC1?
If it's too high risk, then I'll need to look at a workaround (I think I know of one)...
Comment 2 Felipe Heidrich CLA 2011-06-07 16:40:17 EDT
Yes I can, the code is simple to change.
But we need to be careful, if the action handler does not explicitly returns true or false, javascript will put undefined there. Which has the value of false in an if statement. So instead of doing
if (!a.userHandler()) maybe is better to use if (a.userHandler() === false) to make sure the action propagation only proceeds when the user handler explicitly returns false.

Silenio:
As for invokeAction, I don't think it will change. cause the doc says it returns true when a handler is called (which means to me that is doesn't matter what the handler returns, as long the name has handler the invokeAction returns true...
Comment 3 Felipe Heidrich CLA 2011-06-08 11:38:25 EDT
fixed 
http://git.eclipse.org/c/e4/org.eclipse.orion.client.git/commit/?id=92590403058b6f1cfbf0c432674fa3b56fe9821e

the doc in setAction() says: 
" If the given handler returns <code>true</code>, the default action handler is not called."

so, the handler has to explicitly return true to stop the action, not returning or returning false will allow the text view handler (or user-agent default handle) to run.