Bug 97434 (port to toolkit) Some Windows keyboard behaviours missing from trees r=mconnor

This commit is contained in:
cbiesinger%web.de 2004-10-03 16:31:15 +00:00
Родитель 6ac02e52ed
Коммит 2e3390880b
1 изменённых файлов: 55 добавлений и 97 удалений

Просмотреть файл

@ -259,7 +259,7 @@
<handler event="keypress" keycode="vk_return" action="this.changeOpenState(this.currentIndex);"/> <handler event="keypress" keycode="vk_return" action="this.changeOpenState(this.currentIndex);"/>
<handler event="keypress" keycode="vk_left"> <handler event="keypress" keycode="vk_left">
<![CDATA[ <![CDATA[
if (!changeOpenState(this.currentIndex, false)) { if (!this.changeOpenState(this.currentIndex, false)) {
var parentIndex = this.view.getParentIndex(this.currentIndex); var parentIndex = this.view.getParentIndex(this.currentIndex);
if (parentIndex >= 0) { if (parentIndex >= 0) {
this.view.selection.select(parentIndex); this.view.selection.select(parentIndex);
@ -284,27 +284,42 @@
} }
]]> ]]>
</handler> </handler>
<handler event="keypress" keycode="vk_up"> <handler event="keypress" keycode="vk_up" modifiers="control any">
<![CDATA[ <![CDATA[
if (event.ctrlKey && this.view.selection.single) {
this.treeBoxObject.scrollByLines(-1);
return;
}
var c = this.currentIndex; var c = this.currentIndex;
if (c == -1 || c == 0) if (c == -1 || c == 0)
return; return;
this.view.selection.timedSelect(c-1, this._selectDelay); if (!event.ctrlKey)
this.view.selection.timedSelect(c - 1, this._selectDelay);
else // Ctrl+Up moves the anchor without selecting
this.currentIndex = c - 1;
this.treeBoxObject.ensureRowIsVisible(c-1); this.treeBoxObject.ensureRowIsVisible(c-1);
]]> ]]>
</handler> </handler>
<handler event="keypress" keycode="vk_down"> <handler event="keypress" keycode="vk_down" modifiers="control any">
<![CDATA[ <![CDATA[
if (event.ctrlKey && this.view.selection.single) {
this.treeBoxObject.scrollByLines(1);
return;
}
var c = this.currentIndex; var c = this.currentIndex;
try { try {
if (c+1 == this.view.rowCount) if (c+1 == this.view.rowCount)
return; return;
} catch (e) {} } catch (e) {}
this.view.selection.timedSelect(c+1, this._selectDelay); if (!event.ctrlKey)
this.view.selection.timedSelect(c+1, this._selectDelay);
else // Ctrl+Down moves the anchor without selecting
this.currentIndex = c + 1;
this.treeBoxObject.ensureRowIsVisible(c+1); this.treeBoxObject.ensureRowIsVisible(c+1);
]]> ]]>
</handler> </handler>
<handler event="keypress" keycode="vk_up" modifiers="shift"> <handler event="keypress" keycode="vk_up" modifiers="control any, shift">
<![CDATA[ <![CDATA[
if (this.view.selection.single) if (this.view.selection.single)
return; return;
@ -312,11 +327,11 @@
if (c == -1 || c == 0) if (c == -1 || c == 0)
return; return;
// Extend the selection from the existing pivot, if any // Extend the selection from the existing pivot, if any
this.view.selection.rangedSelect(-1, c - 1, false); this.view.selection.rangedSelect(-1, c - 1, event.ctrlKey);
this.treeBoxObject.ensureRowIsVisible(c - 1); this.treeBoxObject.ensureRowIsVisible(c - 1);
]]> ]]>
</handler> </handler>
<handler event="keypress" keycode="vk_down" modifiers="shift"> <handler event="keypress" keycode="vk_down" modifiers="control any, shift">
<![CDATA[ <![CDATA[
if (this.view.selection.single) if (this.view.selection.single)
return; return;
@ -326,33 +341,13 @@
return; return;
} catch (e) {} } catch (e) {}
// Extend the selection from the existing pivot, if any // Extend the selection from the existing pivot, if any
this.view.selection.rangedSelect(-1, c + 1, false); this.view.selection.rangedSelect(-1, c + 1, event.ctrlKey);
this.treeBoxObject.ensureRowIsVisible(c + 1); this.treeBoxObject.ensureRowIsVisible(c + 1);
]]> ]]>
</handler> </handler>
<handler event="keypress" keycode="vk_up" modifiers="control"> <handler event="keypress" keycode="vk_page_up" modifiers="control any">
<![CDATA[ <![CDATA[
var c = this.currentIndex; if (this.pageUpOrDownMovesSelection == event.ctrlKey) {
if (c == -1 || c == 0)
return;
this.currentIndex = c-1;
this.treeBoxObject.ensureRowIsVisible(c-1);
]]>
</handler>
<handler event="keypress" keycode="vk_down" modifiers="control">
<![CDATA[
var c = this.currentIndex;
try {
if (c+1 == this.view.rowCount)
return;
} catch (e) {}
this.currentIndex = c+1;
this.treeBoxObject.ensureRowIsVisible(c+1);
]]>
</handler>
<handler event="keypress" keycode="vk_page_up">
<![CDATA[
if (! this.pageUpOrDownMovesSelection) {
this.treeBoxObject.scrollByPages(-1); this.treeBoxObject.scrollByPages(-1);
return; return;
} }
@ -372,9 +367,9 @@
this.view.selection.timedSelect(i, this._selectDelay); this.view.selection.timedSelect(i, this._selectDelay);
]]> ]]>
</handler> </handler>
<handler event="keypress" keycode="vk_page_down"> <handler event="keypress" keycode="vk_page_down" modifiers="control any">
<![CDATA[ <![CDATA[
if (! this.pageUpOrDownMovesSelection) { if (this.pageUpOrDownMovesSelection == event.ctrlKey) {
this.treeBoxObject.scrollByPages(1); this.treeBoxObject.scrollByPages(1);
return; return;
} }
@ -396,7 +391,7 @@
this.view.selection.timedSelect(i, this._selectDelay); this.view.selection.timedSelect(i, this._selectDelay);
]]> ]]>
</handler> </handler>
<handler event="keypress" keycode="vk_page_up" modifiers="shift"> <handler event="keypress" keycode="vk_page_up" modifiers="control any, shift">
<![CDATA[ <![CDATA[
if (this.view.selection.single) if (this.view.selection.single)
return; return;
@ -414,10 +409,10 @@
this.treeBoxObject.scrollByPages(-1); this.treeBoxObject.scrollByPages(-1);
} }
// Extend the selection from the existing pivot, if any // Extend the selection from the existing pivot, if any
this.view.selection.rangedSelect(-1, i, false); this.view.selection.rangedSelect(-1, i, event.ctrlKey);
]]> ]]>
</handler> </handler>
<handler event="keypress" keycode="vk_page_down" modifiers="shift"> <handler event="keypress" keycode="vk_page_down" modifiers="control any, shift">
<![CDATA[ <![CDATA[
if (this.view.selection.single) if (this.view.selection.single)
return; return;
@ -437,89 +432,52 @@
this.treeBoxObject.scrollByPages(1); this.treeBoxObject.scrollByPages(1);
} }
// Extend the selection from the existing pivot, if any // Extend the selection from the existing pivot, if any
this.view.selection.rangedSelect(-1, i, false); this.view.selection.rangedSelect(-1, i, event.ctrlKey);
]]> ]]>
</handler> </handler>
<handler event="keypress" keycode="vk_page_up" modifiers="control"> <handler event="keypress" keycode="vk_home" modifiers="control any">
<![CDATA[ <![CDATA[
var c = this.currentIndex; if (this.view.rowCount == 0)
if (c == 0)
return; return;
var f = this.treeBoxObject.getFirstVisibleRow(); // Normal behaviour is to select the first row
var i = 0; if (!event.ctrlKey)
if (f > 0) { this.view.selection.timedSelect(0, this._selectDelay);
var p = this.treeBoxObject.getPageLength(); // In a multiselect tree Ctrl+Home moves the anchor
if (f - p >= 0) else if (!this.view.selection.single)
i = c - p; this.currentIndex = 0;
else
i = c - f;
this.treeBoxObject.scrollByPages(-1);
}
this.currentIndex = i;
]]>
</handler>
<handler event="keypress" keycode="vk_page_down" modifiers="control">
<![CDATA[
var c = this.currentIndex;
var l = this.view.rowCount - 1;
if (c == l)
return;
var f = this.treeBoxObject.getFirstVisibleRow();
var p = this.treeBoxObject.getPageLength();
var i = l;
var lastTopRowIndex = l - p;
if (f <= lastTopRowIndex) {
if (f + p <= lastTopRowIndex)
i = c + p;
else
i = lastTopRowIndex + c - f + 1;
this.treeBoxObject.scrollByPages(1);
}
this.currentIndex = i;
]]>
</handler>
<handler event="keypress" keycode="vk_home">
<![CDATA[
this.view.selection.timedSelect(0, this._selectDelay);
this.treeBoxObject.ensureRowIsVisible(0); this.treeBoxObject.ensureRowIsVisible(0);
]]> ]]>
</handler> </handler>
<handler event="keypress" keycode="vk_end"> <handler event="keypress" keycode="vk_end" modifiers="control any">
<![CDATA[ <![CDATA[
var l = this.view.rowCount - 1; var l = this.view.rowCount - 1;
this.view.selection.timedSelect(l, this._selectDelay); if (l < 0)
return;
// Normal behaviour is to select the last row
if (!event.ctrlKey)
this.view.selection.timedSelect(l, this._selectDelay);
// In a multiselect tree Ctrl+End moves the anchor
else if (!this.view.selection.single)
this.currentIndex = l;
this.treeBoxObject.ensureRowIsVisible(l); this.treeBoxObject.ensureRowIsVisible(l);
]]> ]]>
</handler> </handler>
<handler event="keypress" keycode="vk_home" modifiers="shift"> <handler event="keypress" keycode="vk_home" modifiers="control any, shift">
<![CDATA[ <![CDATA[
if (this.view.selection.single) if (this.view.selection.single)
return; return;
// Extend the selection from the existing pivot, if any // Extend the selection from the existing pivot, if any
this.view.selection.rangedSelect(-1, 0, false); this.view.selection.rangedSelect(-1, 0, event.ctrlKey);
this.treeBoxObject.ensureRowIsVisible(0); this.treeBoxObject.ensureRowIsVisible(0);
]]> ]]>
</handler> </handler>
<handler event="keypress" keycode="vk_end" modifiers="shift"> <handler event="keypress" keycode="vk_end" modifiers="control any, shift">
<![CDATA[ <![CDATA[
if (this.view.selection.single) if (this.view.selection.single)
return; return;
var l = this.view.rowCount - 1; var l = this.view.rowCount - 1;
// Extend the selection from the existing pivot, if any // Extend the selection from the existing pivot, if any
this.view.selection.rangedSelect(-1, l, false); this.view.selection.rangedSelect(-1, l, event.ctrlKey);
this.treeBoxObject.ensureRowIsVisible(l);
]]>
</handler>
<handler event="keypress" keycode="vk_home" modifiers="control">
<![CDATA[
this.currentIndex = 0;
this.treeBoxObject.ensureRowIsVisible(0);
]]>
</handler>
<handler event="keypress" keycode="vk_end" modifiers="control">
<![CDATA[
var l = this.view.rowCount - 1;
this.currentIndex = l;
this.treeBoxObject.ensureRowIsVisible(l); this.treeBoxObject.ensureRowIsVisible(l);
]]> ]]>
</handler> </handler>