PDA

View Full Version : [CLOSED] KeyMap inside Panel not working



Fredrik
Apr 02, 2012, 9:57 AM
I can't get a KeyMap inside a panel to work. Am I doing something wrong here or is this a beta feature :-)



<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Bug1.aspx.cs" Inherits="PagingStoreTest.Bug1" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Viewport ID="Viewport1" runat="server" Layout="VBoxLayout">
<LayoutConfig>
<ext:VBoxLayoutConfig Align="Stretch" />
</LayoutConfig>
<Items>
<ext:Panel ID="Panel1" runat="server" Title="Panel1" Flex="1" Height="300">
<KeyMap>
<ext:KeyBinding Alt="true" StopEvent="true">
<Keys>
<ext:Key Code="W" />
</Keys>
<Listeners>
<Event Handler="Ext.Msg.alert('Hello','Hello');" />
</Listeners>
</ext:KeyBinding>
</KeyMap>
</ext:Panel>
</Items>
</ext:Viewport>
</form>
</body>
</html>

Daniil
Apr 02, 2012, 1:23 PM
Hi,

Please see #89:
http://examples2.ext.net/#/Getting_Started/Release_Documents/CHANGELOG/

For now I can suggest to try the following.

Example

<ext:KeyMap runat="server" Target="#{Panel1}.getEl()">
<ext:KeyBinding Alt="true">
<Keys>
<ext:Key Code="W" />
</Keys>
<Listeners>
<Event Handler="Ext.Msg.alert('Hello','Hello');" />
</Listeners>
</ext:KeyBinding>
</ext:KeyMap>

But I think it won't work in all browsers, because the Panel getEl returns a "div" element which, by standard, doesn't listen key events.

It will work if, for example, there is a focused TextField in that Panel. Aslo it will work for GridPanel, because there is an anchor (<a>) HTML element to support cell/row focusing.

Generally, I would suggest to use KeyMap for elements which listen key events itself. For example:
http://examples2.ext.net/#/Keys/KeyMap/BorderLayout_Regions_Toggle/

Fredrik
Apr 02, 2012, 2:51 PM
I will try to create a external KeyMap as you suggest and set the Target property. Thanks