(event)
| 159 | } |
| 160 | |
| 161 | handleMouseDown(event) { |
| 162 | const mainClass = event.target.classList[0]; |
| 163 | if (mainClass === 'ptro-crp-el') { |
| 164 | if (!this.active) { |
| 165 | this.input.innerHTML = '<br>'; |
| 166 | this.pendingClear = true; |
| 167 | } |
| 168 | this.active = true; |
| 169 | this.crd = [ |
| 170 | (event.clientX - this.main.elLeft()) + this.main.scroller.scrollLeft, |
| 171 | (event.clientY - this.main.elTop()) + this.main.scroller.scrollTop, |
| 172 | ]; |
| 173 | const scale = this.main.getScale(); |
| 174 | this.scaledCord = [this.crd[0] * scale, this.crd[1] * scale]; |
| 175 | this.inputWrapper.style.left = `${this.crd[0]}px`; |
| 176 | this.inputWrapper.style.top = `${this.crd[1]}px`; |
| 177 | this.inputWrapper.style.display = 'inline'; |
| 178 | this.input.focus(); |
| 179 | this.reLimit(); |
| 180 | this.input.onkeydown = (e) => { |
| 181 | if (e.ctrlKey && e.keyCode === KEYS.enter) { |
| 182 | this.apply(); |
| 183 | e.preventDefault(); |
| 184 | } |
| 185 | if (e.keyCode === KEYS.esc) { |
| 186 | this.close(); |
| 187 | this.main.closeActiveTool(); |
| 188 | e.preventDefault(); |
| 189 | } |
| 190 | this.reLimit(); |
| 191 | if (this.pendingClear) { |
| 192 | this.input.innerText = this.input.innerText.slice(1); |
| 193 | this.pendingClear = false; |
| 194 | } |
| 195 | e.stopPropagation(); |
| 196 | }; |
| 197 | if (!this.main.isMobile) { |
| 198 | event.preventDefault(); |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | apply() { |
| 204 | const origBorder = this.input.style.border; |
no test coverage detected