|
Rank: Advanced Member Groups: Member
Joined: 11/13/2008 Posts: 43
|
Hi,
I understand from a previous thread that it's not possible to prevent the Escape key from closing an eo:Dialog. I'm really puzzled by this...
I tend to use dialogs in web apps to allow users e.g. to add new records etc, and it's really irritating if someone is half-way through making some data changes and hit the Escape key by accident.
You've obviously added the Escape key functionality, so how hard would it be to wrap this in a boolean?
Also, the Close [X] button in the top-right corner of an eo:Dialog seems to be set to fire on the MouseDown event rather than the MouseClick or MouseUp event. This is completely non-standard behaviour. Can it be changed so that it traps the MouseClick or, even better, MouseUp event instead?
Thanks
Mark
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,200
|
Hi, We looked into the ESC key issue further and realized that actually our developer has already put that in. :) You would need to handle the dialog's ClientSideOnCancel event to do that. It will be something like this:
Code: JavaScript
function cancel_handler()
{
return confirm("Are you sure?");
}
Code: HTML/ASPX
<eo:Dialog ClientSideOnCancel="cancel_handler" ....>
....
</eo:Dialog>
We will look into the close button issue and see if we can change that. Thanks for your suggestion!
|
|
Rank: Advanced Member Groups: Member
Joined: 11/13/2008 Posts: 43
|
eo_support wrote:You would need to handle the dialog's ClientSideOnCancel event to do that. Thanks for that. I was hoping that I could simply put return false; in the cancel_handler() event, but this actually prevents the Dialog from being closed by clicking the Close button. Do you have a method for differentiating between pressing the Escape key and clicking the Close button...?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,200
|
Hi,
No. I do not believe there is an easy way to do that now. Currently clicking close button works the same way as ESC key because both means "canceling the dialog" and most users don't care about distinguishing the two. We will see if we can pass you the event object in a future release (you can use window.event for now, but that's for IE only) so that you can examine the event object by yourself and determine whether it's an ESC event or something else.
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 11/13/2008 Posts: 43
|
eo_support wrote:No. I do not believe there is an easy way to do that now. Currently clicking close button works the same way as ESC key because both means "canceling the dialog" and most users don't care about distinguishing the two. We will see if we can pass you the event object in a future release (you can use window.event for now, but that's for IE only) so that you can examine the event object by yourself and determine whether it's an ESC event or something else. OK, thanks.
|
|
Rank: Advanced Member Groups: Member
Joined: 11/13/2008 Posts: 43
|
eo_support wrote:you can use window.event for now, but that's for IE only Here's a cross-browser compatible solution for preventing the Escape key from closing the Dialog:
Code: JavaScript
var intKeyCode;
function handleKeyPress(evt)
{
intKeyCode = (window.event) ? event.keyCode : evt.which;
return intKeyCode;
}
document.onkeydown = handleKeyPress;
function cancel_handler()
{
if (intKeyCode == 27) { return false; }
}
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,200
|
This is awesome! Thanks for sharing!
|
|
Rank: Advanced Member Groups: Member
Joined: 11/13/2008 Posts: 43
|
eo_support wrote:This is awesome! Thanks for sharing! Needs a small tweak, as follows:
Code: JavaScript
var intKeyCode;
function handleKeyPress(evt)
{
intKeyCode = (window.event) ? event.keyCode : evt.which;
return intKeyCode;
}
document.onkeydown = handleKeyPress;
function cancel_handler()
{
if (intKeyCode == 27)
{
intKeyCode = 0;
return false;
}
}
Something else you might want to consider is giving the eo:Dialog a 'dirty' property which could be inspected in the client-side events. This would allow developers to inform users that the Dialog contains unsaved edits. Incidentally, this isn't particularly difficult to code manually, but it does involve adding a page-level JavaScript variable to the <script> tag for each Dialog, plus JavaScript handlers to every editable control within the Dialog...
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,200
|
Hi,
As for the dirty flag, we have already considered that and decided against it because every user can have different scenarios. For instance, user can have "completed changes" and "incompleted changes", and they may want "completed changes" to be regarded as dirty and "incompleted changes" to be discarded. Also, not all "changes" can be detected/verified in a unified way. Consider user uses our TabStrip control and changed the active tabs. You won't know that unless you call our client side JavaScript interface. For those reasons we’d prefer to leave that part to the end user.
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 11/13/2008 Posts: 43
|
Back to the Escape key, is is possible to include arguments in the ClientSideOnCancel method? e.g.
Code: HTML/ASPX
ClientSideOnCancel="cancel_handler('Are you sure you want to cancel?')"
Code: JavaScript
function cancel_handler(pstrConfirm)
{
if (intKeyCode == 27)
{
intKeyCode = 0;
return confirm(pstrConfirm);
}
}
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,200
|
Hi, Unfortunately that is not possible. All arguments are provided by our controls, just like your server side Page_Load handler is always called by the page with two pre-defined arguments. You can take a look of this topic to get more details on that: http://www.essentialobjects.com/ViewDoc.aspx?t=clientapi_howto.htmlThanks
|
|