PDA

View Full Version : [CLOSED] Disable backspace (but only when not in textfield/textarea)



CarWise
Sep 10, 2013, 3:00 PM
Hi,

I know how to disable the backspace button, but wondering if it's possible to prevent event only when NOT in textfield/textarea. My users sitll need the possibility to use backspace when typing wrong characters in textfields.

Martin

Daniil
Sep 11, 2013, 6:01 AM
Hi Martin,

Could you, please, demonstrate how do you disable the backspace key?

Probably, you are listening to a key press event and stop the event if backspace. If so, you could analyze a target of the event if it is a TextField/TextArea, do not stop the event.

CarWise
Sep 11, 2013, 9:07 AM
Hi Martin,

Could you, please, demonstrate how do you disable the backspace key?

Probably, you are listening to a key press event and stop the event if backspace. If so, you could analyze a target of the event if it is a TextField/TextArea, do not stop the event.

Well..i thought I had something. In 1.* i used:



<ext:KeyMap runat="server" Target="={Ext.isGecko ? Ext.getDoc() : Ext.getBody()}">
<ext:KeyBinding StopEvent="true">
<Keys>
<ext:Key Code="BACKSPACE" />
</Keys>
</ext:KeyBinding>
</ext:KeyMap>




But it seems that the stopEvent attribute is missing in 2.x ?

Martin

Daniil
Sep 11, 2013, 1:12 PM
You can use DefaultEventAction="StopEvent" instead.

It also requires some handler to be defined.

<ext:KeyMap runat="server" Target="={Ext.isGecko ? Ext.getDoc() : Ext.getBody()}">
<Binding>
<ext:KeyBinding Handler="console.log('just some handler');" DefaultEventAction="StopEvent">
<Keys>
<ext:Key Code="BACKSPACE" />
</Keys>
</ext:KeyBinding>
</Binding>
</ext:KeyMap>

CarWise
Sep 11, 2013, 2:27 PM
You can use DefaultEventAction="StopEvent" instead.

It also requires some handler to be defined.

<ext:KeyMap runat="server" Target="={Ext.isGecko ? Ext.getDoc() : Ext.getBody()}">
<Binding>
<ext:KeyBinding Handler="console.log('just some handler');" DefaultEventAction="StopEvent">
<Keys>
<ext:Key Code="BACKSPACE" />
</Keys>
</ext:KeyBinding>
</Binding>
</ext:KeyMap>

Thanks Daniil,

Will look into your example

Martin