Jul 03, 2017, 3:17 PM
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.
and why the code below not works:
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.
<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:
<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>
Last edited by ArashRahimian; Jul 03, 2017 at 6:47 PM.