Chris Anderson
Top achievements
Rank 1
Chris Anderson
asked on 05 Sep 2012, 01:44 AM
I want to be able to disable default commands on the RadRichTextBox (for example the SaveCommand command), and have their corresponding shortcut keys bubble up the visual tree (so the SaveCommand command's Ctrl+S shortcut can be captured at the Window level). I've tried two methods of disabling a command:
#1 - Disabling the command
#2 - Handling the CommandExecuting event and cancelling the command
Unfortunately these methods seem to still mark the event as handled, and the KeyDown event never gets raised up the visual tree. It seems this is a bug - is there a workaround or fix for it?
Thanks
Chris Anderson
rtb.Commands.SaveCommand.Enabled = false;
#2 - Handling the CommandExecuting event and cancelling the command
void RadRichTextBoxEx_CommandExecuting(object sender, CommandExecutingEventArgs e) { if (e.Command is SaveCommand) e.Cancel = true; }
Unfortunately these methods seem to still mark the event as handled, and the KeyDown event never gets raised up the visual tree. It seems this is a bug - is there a workaround or fix for it?
Thanks
Chris Anderson
6 Answers, 1 is accepted
0
Hello Chris Anderson,
Petya
the Telerik team
As a whole, overriding key bindings is done as shown in this article.
However, there are some limitation and several bindings cannot be overriden. Unfortunately, Ctrl+S is one of them.
I will log this for revision and we will expose a way to override all key bindigs as soon as possible.
Please, excuse us for any inconvenience caused.
Petya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
Chris Anderson
Top achievements
Rank 1
answered on 07 Sep 2012, 09:25 AM
Hi Petya
Thanks for your reply. Moreso than being able to override the shortcut key (I don't want to have to do this for every use of the control), the behaviour that I actually want is that if I disable a command, it should no longer mark the KeyDown/KeyUp events has handled for the command's associated shortcut key. As far as I can guess, this is what is happening, as despite the command being disabled, the RadRichTextBox control is still swallowing its associated shortcut keys, and not allowing the KeyDown/KeyUp events to bubble up the tree.
To reproduce:
1. Disable the SaveCommand command using one of the methods in my first post.
2. Add a KeyDown event handler to the Window, which checks for the Ctrl+S shortcut key.
3. Press Ctrl+S in the RadRichTextBox control.
Current behaviour: the KeyDown event handler at the window level never sees the Ctrl+S shortcut.
Expected behaviour: the KeyDown event handler at the window level should see the Ctrl+S shortcut, as the RadRichTextBox control should not be capturing it anymore.
Thanks
Chris
Thanks for your reply. Moreso than being able to override the shortcut key (I don't want to have to do this for every use of the control), the behaviour that I actually want is that if I disable a command, it should no longer mark the KeyDown/KeyUp events has handled for the command's associated shortcut key. As far as I can guess, this is what is happening, as despite the command being disabled, the RadRichTextBox control is still swallowing its associated shortcut keys, and not allowing the KeyDown/KeyUp events to bubble up the tree.
To reproduce:
1. Disable the SaveCommand command using one of the methods in my first post.
2. Add a KeyDown event handler to the Window, which checks for the Ctrl+S shortcut key.
3. Press Ctrl+S in the RadRichTextBox control.
Current behaviour: the KeyDown event handler at the window level never sees the Ctrl+S shortcut.
Expected behaviour: the KeyDown event handler at the window level should see the Ctrl+S shortcut, as the RadRichTextBox control should not be capturing it anymore.
Thanks
Chris
0
Itamar
Top achievements
Rank 1
answered on 11 Sep 2012, 05:07 PM
Hi Petya,
I also encountered the same issue (and need) to disable the Ctrl+S and handle the same with my own logic.
A solution will be much appreciated
Thanks,
Itamar
I also encountered the same issue (and need) to disable the Ctrl+S and handle the same with my own logic.
A solution will be much appreciated
Thanks,
Itamar
0
Hello Chris and Itamar,
We introduced a change in the API, which should allow you to unregister application command bindings on RadRichTextBox instances. The fix will be provided as part of the 2012 Q2 SP2 release, expected any time now.
To use it in your scenario, you will have to:
Kind regards,
Boby
the Telerik team
We introduced a change in the API, which should allow you to unregister application command bindings on RadRichTextBox instances. The fix will be provided as part of the 2012 Q2 SP2 release, expected any time now.
To use it in your scenario, you will have to:
- Remove RadRichTextBox's binding to ApplicationCommands.Save
- Handle RadRichTextBox.PreviewEditorKeyDown event and set SuppressDefaultAction in the argument to 'true' to suppress the default input handler
Don't hesitate to contact us if you have further questions.
Kind regards,
Boby
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
Chris Anderson
Top achievements
Rank 1
answered on 12 Sep 2012, 10:26 PM
Awesome! Thanks Boby!
Chris
Chris
0
Itamar
Top achievements
Rank 1
answered on 13 Sep 2012, 03:17 PM
Great, looking forward to that.
Itamar
Itamar