mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 08:18:41 +09:00
Eliminated exceptions in event handlers that happen when "this.view" does not exists (empty tree)
This commit is contained in:
parent
4f1fb965c6
commit
17182d8b63
1 changed files with 37 additions and 35 deletions
|
|
@ -737,6 +737,7 @@
|
|||
</handler>
|
||||
<handler event="MozSwipeGesture" preventdefault="true">
|
||||
<![CDATA[
|
||||
if (!this.view) return;
|
||||
// Figure out which row to show
|
||||
let targetRow = 0;
|
||||
|
||||
|
|
@ -756,6 +757,7 @@
|
|||
<handler event="focus">
|
||||
<![CDATA[
|
||||
this.treeBoxObject.focused = true;
|
||||
if (!this.view) return;
|
||||
if (this.currentIndex == -1 && this.view.rowCount > 0) {
|
||||
this.currentIndex = this.treeBoxObject.getFirstVisibleRow();
|
||||
}
|
||||
|
|
@ -778,7 +780,7 @@
|
|||
<!-- Use F2 key to enter text editing. -->
|
||||
<handler event="keydown" keycode="VK_F2">
|
||||
<![CDATA[
|
||||
if (!this._cellSelType)
|
||||
if (!this.view || !this._cellSelType)
|
||||
return;
|
||||
var row = this.currentIndex;
|
||||
var column = this.view.selection.currentColumn;
|
||||
|
|
@ -900,112 +902,112 @@
|
|||
</handler>
|
||||
<handler event="keydown" keycode="VK_UP" modifiers="accel any">
|
||||
<![CDATA[
|
||||
if (this._editingColumn)
|
||||
if (!this.view || this._editingColumn)
|
||||
return;
|
||||
_moveByOffset(-1, 0, event);
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="keydown" keycode="VK_DOWN" modifiers="accel any">
|
||||
<![CDATA[
|
||||
if (this._editingColumn)
|
||||
if (!this.view || this._editingColumn)
|
||||
return;
|
||||
_moveByOffset(1, this.view.rowCount - 1, event);
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="keydown" keycode="VK_UP" modifiers="accel any, shift">
|
||||
<![CDATA[
|
||||
if (this._editingColumn)
|
||||
if (!this.view || this._editingColumn)
|
||||
return;
|
||||
_moveByOffsetShift(-1, 0, event);
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="keydown" keycode="VK_DOWN" modifiers="accel any, shift">
|
||||
<![CDATA[
|
||||
if (this._editingColumn)
|
||||
if (!this.view || this._editingColumn)
|
||||
return;
|
||||
_moveByOffsetShift(1, this.view.rowCount - 1, event);
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="keydown" keycode="VK_PAGE_UP" modifiers="accel any">
|
||||
<![CDATA[
|
||||
if (this._editingColumn)
|
||||
if (!this.view || this._editingColumn)
|
||||
return;
|
||||
_moveByPage(-1, 0, event);
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="keydown" keycode="VK_PAGE_DOWN" modifiers="accel any">
|
||||
<![CDATA[
|
||||
if (this._editingColumn)
|
||||
if (!this.view || this._editingColumn)
|
||||
return;
|
||||
_moveByPage(1, this.view.rowCount - 1, event);
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="keydown" keycode="VK_PAGE_UP" modifiers="accel any, shift">
|
||||
<![CDATA[
|
||||
if (this._editingColumn)
|
||||
if (!this.view || this._editingColumn)
|
||||
return;
|
||||
_moveByPageShift(-1, 0, event);
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="keydown" keycode="VK_PAGE_DOWN" modifiers="accel any, shift">
|
||||
<![CDATA[
|
||||
if (this._editingColumn)
|
||||
if (!this.view || this._editingColumn)
|
||||
return;
|
||||
_moveByPageShift(1, this.view.rowCount - 1, event);
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="keydown" keycode="VK_HOME" modifiers="accel any">
|
||||
<![CDATA[
|
||||
if (this._editingColumn)
|
||||
if (!this.view || this._editingColumn)
|
||||
return;
|
||||
_moveToEdge(0, event);
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="keydown" keycode="VK_END" modifiers="accel any">
|
||||
<![CDATA[
|
||||
if (this._editingColumn)
|
||||
if (!this.view || this._editingColumn)
|
||||
return;
|
||||
_moveToEdge(this.view.rowCount - 1, event);
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="keydown" keycode="VK_HOME" modifiers="accel any, shift">
|
||||
<![CDATA[
|
||||
if (this._editingColumn)
|
||||
if (!this.view || this._editingColumn)
|
||||
return;
|
||||
_moveToEdgeShift(0, event);
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="keydown" keycode="VK_END" modifiers="accel any, shift">
|
||||
<![CDATA[
|
||||
if (this._editingColumn)
|
||||
if (!this.view || this._editingColumn)
|
||||
return;
|
||||
_moveToEdgeShift(this.view.rowCount - 1, event);
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="keypress">
|
||||
<![CDATA[
|
||||
if (this._editingColumn)
|
||||
return;
|
||||
if (!this.view || this._editingColumn)
|
||||
return;
|
||||
|
||||
if (event.charCode == ' '.charCodeAt(0)) {
|
||||
var c = this.currentIndex;
|
||||
if (!this.view.selection.isSelected(c) ||
|
||||
(!this.view.selection.single && this._isAccelPressed(event))) {
|
||||
this.view.selection.toggleSelect(c);
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
else if (!this.disableKeyNavigation && event.charCode > 0 &&
|
||||
!event.altKey && !this._isAccelPressed(event) &&
|
||||
!event.metaKey && !event.ctrlKey) {
|
||||
var l = this._keyNavigate(event);
|
||||
if (l >= 0) {
|
||||
this.view.selection.timedSelect(l, this._selectDelay);
|
||||
this.treeBoxObject.ensureRowIsVisible(l);
|
||||
}
|
||||
event.preventDefault();
|
||||
}
|
||||
]]>
|
||||
if (event.charCode == ' '.charCodeAt(0)) {
|
||||
var c = this.currentIndex;
|
||||
if (!this.view.selection.isSelected(c) ||
|
||||
(!this.view.selection.single && this._isAccelPressed(event))) {
|
||||
this.view.selection.toggleSelect(c);
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
else if (!this.disableKeyNavigation && event.charCode > 0 &&
|
||||
!event.altKey && !this._isAccelPressed(event) &&
|
||||
!event.metaKey && !event.ctrlKey) {
|
||||
var l = this._keyNavigate(event);
|
||||
if (l >= 0) {
|
||||
this.view.selection.timedSelect(l, this._selectDelay);
|
||||
this.treeBoxObject.ensureRowIsVisible(l);
|
||||
}
|
||||
event.preventDefault();
|
||||
}
|
||||
]]>
|
||||
</handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
|
@ -1558,4 +1560,4 @@
|
|||
</handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
</bindings>
|
||||
</bindings>
|
||||
Loading…
Add table
Add a link
Reference in a new issue