* Sets focus. * @param {boolean} focus * @return {View} Fluent interface
(focus)
| 280 | * @return {View} Fluent interface |
| 281 | */ |
| 282 | setFocus (focus) { |
| 283 | if (focus !== this._focus) { |
| 284 | this._focus = focus |
| 285 | if (focus) { |
| 286 | // inform superview |
| 287 | if (this._superview !== null) { |
| 288 | this._superview.subviewDidFocus(this) |
| 289 | } |
| 290 | this.didFocus() |
| 291 | } else { |
| 292 | // blur subviews |
| 293 | this._subviews.forEach(subview => subview.blur()) |
| 294 | this.didBlur() |
| 295 | } |
| 296 | } |
| 297 | return this |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * Returns true, if view or one of the subviews has focus. |