InputBinding does not work

SyntaxEditor for Silverlight Forum

Posted 8 years ago by Alexey Lavnikov
Version: 16.1.0201
Platform: Silverlight 5
Avatar

Hi there,

I've just registered my command to show find/replace dialog on Ctrl+F/Ctrl+H.

However, syntax editor does not call underlying execute method of ICommand.

This issue is easy to reproduce, just go to syntax editor sample browser and select Edit Actions example.
There is "Bind to Ctrl+M" button to click. Then obviously, Ctrl+M should work, but it does not.

Best wishes,
Lex

 

BTW. There is also problem with this web site, Create Thread as well as Complete Order buttons do not work in IE11 (and you must know, that IE11 is the last browser to support Silverlight, right?).

Comments (3)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Lex,

Those hotkeys are intercepted by the browser itself.  Unfortunately if the browser grabs them, then Silverlight (and thus our control) never gets them.  They would probably work if you ran your app as Silverlight out of browser.  I tested Ctrl+M and it does seem to be intercepted now (it didn't used to be).  If you change the code in that sample to Ctrl+Q, it will work since that hotkey isn't consumed by the browser.

I tested the web site's Create Thread button just now in IE 11 and it worked ok.  It's using Javascript so it could be that you have JS disabled in your IE 11 settings?


Actipro Software Support

Posted 8 years ago by Alexey Lavnikov
Avatar

Regarding JS:

No, JS is not blocked, IE11 in default configuration on Windows 10. Clicking Create Thread, Complete Order (and now Post Comment) scrolls page on top. In Chrome works fine.

Regarding InputBindings:

Shortcuts do not work both in browser and in out-of-browser mode. Has nothing to do with browser, because when I attach OnKeyDown event handler, I can successfully intercept these keystrokes.

_editor.InputBindings.Insert(0, new KeyBinding(new UICommand(OnCtrlF), Key.F, ModifierKeys.Control));
_editor.InputBindings.Insert(0, new KeyBinding(new UICommand(OnCtrlH), Key.H, ModifierKeys.Control));

void OnCtrlF()
{
Debugger.Break();
}

void OnCtrlH()
{
Debugger.Break();
}

where UICommand:

class UICommand : ICommand
{
readonly Action _action;

public UICommand(Action action)
{
_action = action;
}

public event EventHandler CanExecuteChanged;

public bool CanExecute(object parameter)
{
return true;
}

public void Execute(object parameter)
{
_action();
}
}

Should work, right?

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

The other thing to consider is that if the browser isn't intercepting the key, it could be that we already have a SyntaxEditor.InputBindings entry for that key combination.  Did you run through to remove any other KeyBindings with the same keys?  Note that our code does a reverse (not a forward) loop through the collection when looking for a match.


Actipro Software Support

The latest build of this product (v18.1 build 0233) was released 4 years ago, which was after the last post in this thread.