-
Problem on Key binding
Hi there
My problem is when I use the code below in two windows that are opened in Desktop control, assigned short keys will raising button click event of the first added window not in second one.
Code:
<ext:ButtonGroup ID="ButtonGroupClipboard" runat="server" Title="Clipboard" Columns="4">
<Content>
<ext:KeyMap runat="server" Target="#{ContentPanel}">
<Binding>
<ext:KeyBinding Ctrl="True" Handler="#{ButtonCopy}.fireEvent('click');">
<Keys>
<ext:Key Code="C"/>
</Keys>
</ext:KeyBinding>
<ext:KeyBinding Ctrl="True" Handler="#{ButtonPaste}.fireEvent('click');">
<Keys>
<ext:Key Code="V"/>
</Keys>
</ext:KeyBinding>
<ext:KeyBinding Ctrl="True" Handler="#{ButtonCut}.fireEvent('click');">
<Keys>
<ext:Key Code="X"/>
</Keys>
</ext:KeyBinding>
</Binding>
</ext:KeyMap>
</Content>
<Items>
<diten:Button ID="ButtonPinTo" runat="server" Text="Pin to Quick access" OverflowText="Pin..." Scale="Large" IconAlign="Top" RowSpan="3" ToolTip="Pin folder to quick access" OnClick="ButtonPinTo_Click"/>
<diten:Button ID="ButtonCopy" runat="server" Text="Copy" Icon="PageCopy" Scale="Large" IconAlign="Top" RowSpan="3" ToolTip="Copy the selected items to clipboard (Ctrl+C)." OnClick="ButtonCopy_Click"/>
<diten:Button ID="ButtonPaste" runat="server" Text="Paste" Icon="PagePaste" Scale="Large" IconAlign="Top" RowSpan="3" ToolTip="Paste the contents of Clipboard to the curent location. (Ctrl+V)" OnClick="ButtonPaste_Click"/>
<diten:Button ID="ButtonCut" runat="server" Text="Cut" Icon="Cut" ToolTip="Move the selected items to the Clipboard. (Ctrl+X)" OnClick="ButtonCut_Click"/>
<diten:Button ID="ButtonCopyPath" runat="server" Text="Copy path" Icon="PageCopy" ToolTip="Copy the path of selected items to the Clipboard." OnClick="ButtonCopyPath_Click"/>
<diten:Button ID="ButtonPasteShorcut" runat="server" Text="Paste shorcut" Icon="PagePaste" ToolTip="Paste shortcuts to the items on the Clipboard." OnClick="ButtonPasteShorcut_Click"/>
</Items>
<Content>
</Content>
</ext:ButtonGroup>
I found a way for solving this problem but it's not pratic. After some research I found out ID of Buttons must not be the same in windows. for example if in window A and in window B we set ButtonCopy as ID of copy button Handler of KeyBinding can not diagnose these two buttons are in separated windows. If we change ID of button in window A to WindowA_ButtonCopy and in window B we set it to WindowB_ButtonCopy, Handler of KeyBinding will works fine but if we use same ID for buttons in Window A and window B handler could not diagnose window B ButtonCopy.
and why the code below not works:
Code:
<diten:Button ID="ButtonCopy" runat="server" Text="Copy" Icon="PageCopy" Scale="Large" IconAlign="Top" RowSpan="3" ToolTip="Copy the selected items to clipboard (Ctrl+C)." OnClick="ButtonCopy_Click">
<KeyMap Target="#{ContentPanel}">
<Binding>
<ext:KeyBinding Ctrl="True" Handler="#{ButtonCopy}.fireEvent('click');">
<Keys>
<ext:Key Code="C"/>
</Keys>
</ext:KeyBinding>
</Binding>
</KeyMap>
</diten:Button>
-
Hello @ArashRahimian!
Thanks for sharing your experience with the issue. This is something really broken in current Ext.NET code, but has some known workarounds that could work nicer for you, not sure in the context of having user controls. There's an open issue with this issue (as long as it is not specific to user controls) at Keymap in gridpanel not working. I believe during your research you probably been thru this thread but felt like sharing the topic here for a related (closely) issue that's currently open.
We really should review this key mapping issue for our next release, 4.3.0. Interesting that it has been out at least since 4.0.0 but took a while to be raised.
Well, if you weren't aware of the topic above, please give it a look, it may bring useful insight for better approaches to binding keys on current Ext.NET versions.
-
TX for reply