Change custom Checkbox to expose an onChange Event instead of taking an onChange callback in options.

Otherwise it's impossible to reference the checkbox from inside the callback while constructing a Checkbox
This commit is contained in:
Rob Lourens
2018-06-22 12:54:17 -07:00
parent bf4f7de576
commit e0fbb4294b
9 changed files with 82 additions and 84 deletions

View File

@@ -293,48 +293,50 @@ export class FindInput extends Widget {
this.regex = this._register(new RegexCheckbox({
appendTitle: appendRegexLabel,
isChecked: false,
onChange: (viaKeyboard) => {
this._onDidOptionChange.fire(viaKeyboard);
if (!viaKeyboard) {
this.inputBox.focus();
}
this.setInputWidth();
this.validate();
},
onKeyDown: (e) => {
this._onRegexKeyDown.fire(e);
},
inputActiveOptionBorder: this.inputActiveOptionBorder
}));
this._register(this.regex.onChange(viaKeyboard => {
this._onDidOptionChange.fire(viaKeyboard);
if (!viaKeyboard) {
this.inputBox.focus();
}
this.setInputWidth();
this.validate();
}));
this._register(this.regex.onKeyDown(e => {
this._onRegexKeyDown.fire(e);
}));
this.wholeWords = this._register(new WholeWordsCheckbox({
appendTitle: appendWholeWordsLabel,
isChecked: false,
onChange: (viaKeyboard) => {
this._onDidOptionChange.fire(viaKeyboard);
if (!viaKeyboard) {
this.inputBox.focus();
}
this.setInputWidth();
this.validate();
},
inputActiveOptionBorder: this.inputActiveOptionBorder
}));
this._register(this.wholeWords.onChange(viaKeyboard => {
this._onDidOptionChange.fire(viaKeyboard);
if (!viaKeyboard) {
this.inputBox.focus();
}
this.setInputWidth();
this.validate();
}));
this.caseSensitive = this._register(new CaseSensitiveCheckbox({
appendTitle: appendCaseSensitiveLabel,
isChecked: false,
onChange: (viaKeyboard) => {
this._onDidOptionChange.fire(viaKeyboard);
if (!viaKeyboard) {
this.inputBox.focus();
}
this.setInputWidth();
this.validate();
},
onKeyDown: (e) => {
this._onCaseSensitiveKeyDown.fire(e);
},
inputActiveOptionBorder: this.inputActiveOptionBorder
}));
this._register(this.caseSensitive.onChange(viaKeyboard => {
this._onDidOptionChange.fire(viaKeyboard);
if (!viaKeyboard) {
this.inputBox.focus();
}
this.setInputWidth();
this.validate();
}));
this._register(this.caseSensitive.onKeyDown(e => {
this._onCaseSensitiveKeyDown.fire(e);
}));
// Arrow-Key support to navigate between options
let indexes = [this.caseSensitive.domNode, this.wholeWords.domNode, this.regex.domNode];