PDA

View Full Version : [2.??][CLOSED] Ext.MessageBox.prompt and tabbing



skitzo
24 Aug 2008, 6:07 AM
I have noticed that when using an Ext.MessageBox.prompt that after entering some text, the tab key doesn't bring you down to the 'ok' button.

Example:



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="lib/ext/resources/css/ext-all.css" />
<script type="text/javascript" src="lib/ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="lib/ext/ext-all-debug.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
Ext.MessageBox.prompt("Tab Text", "Enter some text then hit 'TAB'");
});
</script>
</head>
<body>
</body>
</html>

There is probably a better way, but this is how I fixed the problem:

in ext-all-debug.js,
in Ext.MessageBox = function(){,
in getDialog:

I changed these lines:


buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
to



buttons["ok"] = dlg.addButton({text: bt["ok"], tabIndex: 1}, handleButton.createCallback("ok"));
buttons["yes"] = dlg.addButton({text: bt["yes"], tabIndex: 1}, handleButton.createCallback("yes"));
buttons["no"] = dlg.addButton({text: bt["no"], tabIndex: 2}, handleButton.createCallback("no"));
buttons["cancel"] = dlg.addButton({text: bt["cancel"], tabIndex: 2}, handleButton.createCallback("cancel"));

mjlecomte
24 Aug 2008, 6:47 AM
I do not think this is a bug. This is a feature request. Set up a keyMap or specialKeys, etc. as needed for the various components to handle the keyboard behavior you want.

skitzo
24 Aug 2008, 6:57 AM
Fair enough. :)

What do you think would be the best way for me to modify the existing behavior. I'm guess that the source code mod probably isn't the most desirable.

Would it be better/easier/more elegant to extend the MessageBox, make a plugin, or (as you mentioned) capture key events or use keymaps?

Thanks

mjlecomte
24 Aug 2008, 7:05 AM
I guess it depends how you perceive the usage. If you always want the behavior then override Ext.whatever. If you only want it sometimes then extend with Ext.ux.whatever. If it's for specific cases then maybe look to key handling alternatives. But modifying the original is probably the worst thing you can do since you'll lose your changes with any updates. At least with overrides you can include or not include the override. If you extend then your code is kind of bound to the extension even with updates since you'll be pointing to your extension and not Ext anymore.

Undoubtedly someone else may have better suggestion.

skitzo
24 Aug 2008, 8:56 AM
Ok, I think an override will probably be the best option then.

Thanks for your help. :D