зеркало из https://github.com/mozilla/gecko-dev.git
Bug 613760 - Tab-modal prompt dialog has no default button on os x. r=gavin, a=blocking
This commit is contained in:
Родитель
7be93ae2c5
Коммит
96cb3976d7
|
@ -206,8 +206,6 @@
|
|||
if (action == "default") {
|
||||
let bnum = this.args.defaultButtonNum || 0;
|
||||
let button = this.ui["button" + bnum];
|
||||
if (!button.hasAttribute("default"))
|
||||
return;
|
||||
this.onButtonClick(bnum);
|
||||
} else { // action == "cancel"
|
||||
this.onButtonClick(1); // Cancel button
|
||||
|
@ -225,14 +223,31 @@
|
|||
group="system" action="this.onKeyAction('default', event);"/>
|
||||
<handler event="keypress" keycode="VK_ESCAPE"
|
||||
group="system" action="this.onKeyAction('cancel', event);"/>
|
||||
#ifndef XP_MACOSX
|
||||
<handler event="focus" phase="capturing">
|
||||
// Focus shift clears the default button.
|
||||
let bnum = this.args.defaultButtonNum || 0;
|
||||
let defaultButton = this.ui["button" + bnum];
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// On OS X, the default button always stays marked as such (until
|
||||
// the entire prompt blurs).
|
||||
defaultButton.setAttribute("default", true);
|
||||
#else
|
||||
// On other platforms, the default button is only marked as such
|
||||
// when no other button has focus. XUL buttons on not-OSX will
|
||||
// react to pressing enter as a command, so you can't trigger the
|
||||
// default without tabbing to it or something that isn't a button.
|
||||
let focusedDefault = (event.originalTarget == defaultButton);
|
||||
let someButtonFocused = event.originalTarget instanceof Ci.nsIDOMXULButtonElement;
|
||||
defaultButton.setAttribute("default", focusedDefault || !someButtonFocused);
|
||||
#endif
|
||||
</handler>
|
||||
<handler event="blur">
|
||||
// If focus shifted to somewhere else in the browser, don't make
|
||||
// the default button look active.
|
||||
let bnum = this.args.defaultButtonNum || 0;
|
||||
let button = this.ui["button" + bnum];
|
||||
button.setAttribute("default", event.originalTarget == button);
|
||||
button.setAttribute("default", false);
|
||||
</handler>
|
||||
#endif
|
||||
</handlers>
|
||||
|
||||
</binding>
|
||||
|
|
|
@ -179,25 +179,22 @@ CommonDialog.prototype = {
|
|||
this.args.buttonNumClicked = 1;
|
||||
|
||||
|
||||
// If there are no input fields on the dialog, select the default button.
|
||||
// Otherwise, select the appropriate input field.
|
||||
// XXX shouldn't we set an unfocused default even when a textbox is focused?
|
||||
if (!this.hasInputField) {
|
||||
// Set the default button (and focus it on non-OS X systems)
|
||||
let b = 0;
|
||||
if (this.args.defaultButtonNum)
|
||||
b = this.args.defaultButtonNum;
|
||||
let button = this.ui["button" + b];
|
||||
if (xulDialog) {
|
||||
xulDialog.defaultButton = ['accept', 'cancel', 'extra1', 'extra2'][b];
|
||||
let isOSX = ("nsILocalFileMac" in Components.interfaces);
|
||||
if (!isOSX)
|
||||
button.focus();
|
||||
} else {
|
||||
button.setAttribute("default", "true");
|
||||
button.focus();
|
||||
}
|
||||
// Set the default button
|
||||
let b = (this.args.defaultButtonNum || 0)
|
||||
let button = this.ui["button" + b];
|
||||
|
||||
if (xulDialog)
|
||||
xulDialog.defaultButton = ['accept', 'cancel', 'extra1', 'extra2'][b];
|
||||
else
|
||||
button.setAttribute("default", "true");
|
||||
|
||||
// Set default focus / selection.
|
||||
if (!this.hasInputField) {
|
||||
let isOSX = ("nsILocalFileMac" in Components.interfaces);
|
||||
if (isOSX)
|
||||
this.ui.infoBody.focus();
|
||||
else
|
||||
button.focus();
|
||||
} else {
|
||||
if (this.args.promptType == "promptPassword")
|
||||
this.ui.password1Textbox.select();
|
||||
|
|
Загрузка…
Ссылка в новой задаче