mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-11 10:38:37 +08:00
Organizing input actions in device folders
This commit is contained in:
35
js/input/mouse/Unfocus.js
Executable file
35
js/input/mouse/Unfocus.js
Executable file
@@ -0,0 +1,35 @@
|
||||
import Context from "../Context"
|
||||
|
||||
export default class Unfocus extends Context {
|
||||
|
||||
constructor(target, blueprint, options = {}) {
|
||||
options.wantsFocusCallback = true
|
||||
super(target, blueprint, options)
|
||||
|
||||
let self = this
|
||||
this.clickHandler = e => self.clickedSomewhere(e)
|
||||
if (this.blueprint.focuse) {
|
||||
document.addEventListener("click", this.clickHandler)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {MouseEvent} e
|
||||
*/
|
||||
clickedSomewhere(e) {
|
||||
// If target is inside the blueprint grid
|
||||
if (e.target.closest("ueb-blueprint")) {
|
||||
return
|
||||
}
|
||||
this.blueprint.setFocused(false)
|
||||
}
|
||||
|
||||
blueprintFocused() {
|
||||
document.addEventListener("click", this.clickHandler)
|
||||
}
|
||||
|
||||
blueprintUnfocused() {
|
||||
document.removeEventListener("click", this.clickHandler)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user