RealTimeDesigner Support Network
Wiki Forums Libraries Docs Support RealTimeDesigner Home
Welcome! Log In Create A New Profile

Advanced

How to remove the DELETE key listener

Posted by Alex 
How to remove the DELETE key listener
September 12, 2013 04:58AM
This is a nice trick, so I felt to share with you.

In RTD, when you hit the "delete" key on your keyboard, the hit is listened and fires the command to remove a designer item.
However, because the listener is always active, this also means that the alert ("Are you sure you want to remove this item?" ) appears also when you're editing a text, and you hit that key to simply remove the rightmost character.

For some users that's ok, others would prefer to remove such feature.
Removing it means that, to remove an item from the design, clicking the REMOVE button will be the only way (no more keyboard removal).

If this is better or not for you is something only you can decide.
However, if you'd like to remove that, I'm here to show a small trick that will allow you to nullify the listener of the DEL key.

In admin panel, into SYSTEM OPTIONS => Configure Store layouts, select the store you want to disable it for.
Then, add this to the bottom of your FOOTER CODE FOR DESIGNER block:
<script>
function WholeKeyManage(event) {
	var evt = event || window.event;
	var rx = /INPUT|SELECT|TEXTAREA/i;
	if (evt.keyCode==8) {	
		if(!rx.test(evt.target.tagName) || evt.target.disabled || evt.target.readOnly ){
			evt.preventDefault();
		}
	}
}
</script>

This will basically override the original RTD function, and result is that the delete key will be captured no more.
The code you see is needed to avoid voiding the fix added thanks to the comments below.



Edited 2 time(s). Last edit at 09/12/2013 09:48PM by Alex.
cos
Re: How to remove the DELETE key listener
September 12, 2013 06:37AM
For Macs this is different (at least in the latest version 10.8.4). I'm glad you brought this subject to mind as this is a long time issue in a different way.
Coding in the above mentioned trick does nothing on Macs in Safari, Firefox or Google Chrome.

In Safari:
When an rtd text block is selected pressing delete key (there is no backspace key on Macs) deletes one character at a time without warning as expected.
When all other rtd items are selected, pressing the delete key does nothing.

I prefer that behavior. No unexpected surprises.

In Firefox and Chrome, and this is MIND BLOWING STUPID and not the fault of rtd, but of Firefox and Chrome:
When an rtd text block is selected pressing delete key deletes one character at a time without warning as expected.
When all other rtd items are selected, pressing the delete key BROWSES THE WEB PAGE BACK TO THE PREVIOUS PAGE WITHOUT WARNING.
Pressing the browse forward button to return to rtd loads rtd and everything you did in rtd is lost. Poof. Gone.
There's different behavior in both if you started directly in an rtd page, but not worth time to describe at this point.

In Firefox the method for changing this is up the user by changing a config as seen here. Something that ain't gonna happen for users.

In Chrome it's a different story and this discussion in Google groups is interesting.

I'm not testing this morning on Windows, so can't speak regarding Firefox and Chrome there.

You can imagine how many times I, an admin, have hit delete key in rtd. How many times have our customers hit delete key and cried?

So, begs the question . . . Alex, can there be a coding trick to disable these things for Firefox and Chrome when in rtd only?
Re: How to remove the DELETE key listener
September 12, 2013 06:47PM
To keep readers updated: Cos and I did some testing this morning, and I found that even in windows the issue exists.
In Mac it's worst simply because ti seems to have slightly different keys on keyboard (I never noticed as I never had a Mac!)

We're currently doing some testings to see if the issue can be workarounded, but not sure if it's even possible from within a webpage.
I'll post more news as I'll have some results
Re: How to remove the DELETE key listener
September 12, 2013 09:45PM
We found a solution, and It's already live. Seems to work fine!
However, I've edited the hack described in the first post, as the old version would also void this fix too.

Thanks Cos for the help in testing!
Sorry, only registered users may post in this forum.

Click here to login