mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-27 01:27:30 +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>
|
||||||
<handler event="MozSwipeGesture" preventdefault="true">
|
<handler event="MozSwipeGesture" preventdefault="true">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
|
if (!this.view) return;
|
||||||
// Figure out which row to show
|
// Figure out which row to show
|
||||||
let targetRow = 0;
|
let targetRow = 0;
|
||||||
|
|
||||||
|
|
@ -756,6 +757,7 @@
|
||||||
<handler event="focus">
|
<handler event="focus">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
this.treeBoxObject.focused = true;
|
this.treeBoxObject.focused = true;
|
||||||
|
if (!this.view) return;
|
||||||
if (this.currentIndex == -1 && this.view.rowCount > 0) {
|
if (this.currentIndex == -1 && this.view.rowCount > 0) {
|
||||||
this.currentIndex = this.treeBoxObject.getFirstVisibleRow();
|
this.currentIndex = this.treeBoxObject.getFirstVisibleRow();
|
||||||
}
|
}
|
||||||
|
|
@ -778,7 +780,7 @@
|
||||||
<!-- Use F2 key to enter text editing. -->
|
<!-- Use F2 key to enter text editing. -->
|
||||||
<handler event="keydown" keycode="VK_F2">
|
<handler event="keydown" keycode="VK_F2">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (!this._cellSelType)
|
if (!this.view || !this._cellSelType)
|
||||||
return;
|
return;
|
||||||
var row = this.currentIndex;
|
var row = this.currentIndex;
|
||||||
var column = this.view.selection.currentColumn;
|
var column = this.view.selection.currentColumn;
|
||||||
|
|
@ -900,112 +902,112 @@
|
||||||
</handler>
|
</handler>
|
||||||
<handler event="keydown" keycode="VK_UP" modifiers="accel any">
|
<handler event="keydown" keycode="VK_UP" modifiers="accel any">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (this._editingColumn)
|
if (!this.view || this._editingColumn)
|
||||||
return;
|
return;
|
||||||
_moveByOffset(-1, 0, event);
|
_moveByOffset(-1, 0, event);
|
||||||
]]>
|
]]>
|
||||||
</handler>
|
</handler>
|
||||||
<handler event="keydown" keycode="VK_DOWN" modifiers="accel any">
|
<handler event="keydown" keycode="VK_DOWN" modifiers="accel any">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (this._editingColumn)
|
if (!this.view || this._editingColumn)
|
||||||
return;
|
return;
|
||||||
_moveByOffset(1, this.view.rowCount - 1, event);
|
_moveByOffset(1, this.view.rowCount - 1, event);
|
||||||
]]>
|
]]>
|
||||||
</handler>
|
</handler>
|
||||||
<handler event="keydown" keycode="VK_UP" modifiers="accel any, shift">
|
<handler event="keydown" keycode="VK_UP" modifiers="accel any, shift">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (this._editingColumn)
|
if (!this.view || this._editingColumn)
|
||||||
return;
|
return;
|
||||||
_moveByOffsetShift(-1, 0, event);
|
_moveByOffsetShift(-1, 0, event);
|
||||||
]]>
|
]]>
|
||||||
</handler>
|
</handler>
|
||||||
<handler event="keydown" keycode="VK_DOWN" modifiers="accel any, shift">
|
<handler event="keydown" keycode="VK_DOWN" modifiers="accel any, shift">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (this._editingColumn)
|
if (!this.view || this._editingColumn)
|
||||||
return;
|
return;
|
||||||
_moveByOffsetShift(1, this.view.rowCount - 1, event);
|
_moveByOffsetShift(1, this.view.rowCount - 1, event);
|
||||||
]]>
|
]]>
|
||||||
</handler>
|
</handler>
|
||||||
<handler event="keydown" keycode="VK_PAGE_UP" modifiers="accel any">
|
<handler event="keydown" keycode="VK_PAGE_UP" modifiers="accel any">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (this._editingColumn)
|
if (!this.view || this._editingColumn)
|
||||||
return;
|
return;
|
||||||
_moveByPage(-1, 0, event);
|
_moveByPage(-1, 0, event);
|
||||||
]]>
|
]]>
|
||||||
</handler>
|
</handler>
|
||||||
<handler event="keydown" keycode="VK_PAGE_DOWN" modifiers="accel any">
|
<handler event="keydown" keycode="VK_PAGE_DOWN" modifiers="accel any">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (this._editingColumn)
|
if (!this.view || this._editingColumn)
|
||||||
return;
|
return;
|
||||||
_moveByPage(1, this.view.rowCount - 1, event);
|
_moveByPage(1, this.view.rowCount - 1, event);
|
||||||
]]>
|
]]>
|
||||||
</handler>
|
</handler>
|
||||||
<handler event="keydown" keycode="VK_PAGE_UP" modifiers="accel any, shift">
|
<handler event="keydown" keycode="VK_PAGE_UP" modifiers="accel any, shift">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (this._editingColumn)
|
if (!this.view || this._editingColumn)
|
||||||
return;
|
return;
|
||||||
_moveByPageShift(-1, 0, event);
|
_moveByPageShift(-1, 0, event);
|
||||||
]]>
|
]]>
|
||||||
</handler>
|
</handler>
|
||||||
<handler event="keydown" keycode="VK_PAGE_DOWN" modifiers="accel any, shift">
|
<handler event="keydown" keycode="VK_PAGE_DOWN" modifiers="accel any, shift">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (this._editingColumn)
|
if (!this.view || this._editingColumn)
|
||||||
return;
|
return;
|
||||||
_moveByPageShift(1, this.view.rowCount - 1, event);
|
_moveByPageShift(1, this.view.rowCount - 1, event);
|
||||||
]]>
|
]]>
|
||||||
</handler>
|
</handler>
|
||||||
<handler event="keydown" keycode="VK_HOME" modifiers="accel any">
|
<handler event="keydown" keycode="VK_HOME" modifiers="accel any">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (this._editingColumn)
|
if (!this.view || this._editingColumn)
|
||||||
return;
|
return;
|
||||||
_moveToEdge(0, event);
|
_moveToEdge(0, event);
|
||||||
]]>
|
]]>
|
||||||
</handler>
|
</handler>
|
||||||
<handler event="keydown" keycode="VK_END" modifiers="accel any">
|
<handler event="keydown" keycode="VK_END" modifiers="accel any">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (this._editingColumn)
|
if (!this.view || this._editingColumn)
|
||||||
return;
|
return;
|
||||||
_moveToEdge(this.view.rowCount - 1, event);
|
_moveToEdge(this.view.rowCount - 1, event);
|
||||||
]]>
|
]]>
|
||||||
</handler>
|
</handler>
|
||||||
<handler event="keydown" keycode="VK_HOME" modifiers="accel any, shift">
|
<handler event="keydown" keycode="VK_HOME" modifiers="accel any, shift">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (this._editingColumn)
|
if (!this.view || this._editingColumn)
|
||||||
return;
|
return;
|
||||||
_moveToEdgeShift(0, event);
|
_moveToEdgeShift(0, event);
|
||||||
]]>
|
]]>
|
||||||
</handler>
|
</handler>
|
||||||
<handler event="keydown" keycode="VK_END" modifiers="accel any, shift">
|
<handler event="keydown" keycode="VK_END" modifiers="accel any, shift">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (this._editingColumn)
|
if (!this.view || this._editingColumn)
|
||||||
return;
|
return;
|
||||||
_moveToEdgeShift(this.view.rowCount - 1, event);
|
_moveToEdgeShift(this.view.rowCount - 1, event);
|
||||||
]]>
|
]]>
|
||||||
</handler>
|
</handler>
|
||||||
<handler event="keypress">
|
<handler event="keypress">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (this._editingColumn)
|
if (!this.view || this._editingColumn)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.charCode == ' '.charCodeAt(0)) {
|
if (event.charCode == ' '.charCodeAt(0)) {
|
||||||
var c = this.currentIndex;
|
var c = this.currentIndex;
|
||||||
if (!this.view.selection.isSelected(c) ||
|
if (!this.view.selection.isSelected(c) ||
|
||||||
(!this.view.selection.single && this._isAccelPressed(event))) {
|
(!this.view.selection.single && this._isAccelPressed(event))) {
|
||||||
this.view.selection.toggleSelect(c);
|
this.view.selection.toggleSelect(c);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!this.disableKeyNavigation && event.charCode > 0 &&
|
else if (!this.disableKeyNavigation && event.charCode > 0 &&
|
||||||
!event.altKey && !this._isAccelPressed(event) &&
|
!event.altKey && !this._isAccelPressed(event) &&
|
||||||
!event.metaKey && !event.ctrlKey) {
|
!event.metaKey && !event.ctrlKey) {
|
||||||
var l = this._keyNavigate(event);
|
var l = this._keyNavigate(event);
|
||||||
if (l >= 0) {
|
if (l >= 0) {
|
||||||
this.view.selection.timedSelect(l, this._selectDelay);
|
this.view.selection.timedSelect(l, this._selectDelay);
|
||||||
this.treeBoxObject.ensureRowIsVisible(l);
|
this.treeBoxObject.ensureRowIsVisible(l);
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
]]>
|
]]>
|
||||||
</handler>
|
</handler>
|
||||||
</handlers>
|
</handlers>
|
||||||
</binding>
|
</binding>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue