From 6c73edd7bf666f4ad0ac7a427701d0d4039ab697 Mon Sep 17 00:00:00 2001 From: "mikep%oeone.com" Date: Thu, 12 Sep 2002 14:20:19 +0000 Subject: [PATCH] Fixing some selection problems in calendar. Select All continues not to work. --- calendar/resources/content/unifinder.js | 62 ++++++++++++++++--------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/calendar/resources/content/unifinder.js b/calendar/resources/content/unifinder.js index 6e9d8c4403d..c22ff9a7c27 100644 --- a/calendar/resources/content/unifinder.js +++ b/calendar/resources/content/unifinder.js @@ -54,43 +54,59 @@ function calendarUnifinderInit( ) { onSelectionChanged : function( EventSelectionArray ) { - // XXX This selection observer needs to be re written. - - // Problems: When selecting everything, - - if( gCalendarEventTreeClicked === false ) - { - var SearchTree = document.getElementById( UnifinderTreeName ); + //dump( "\nCALENDAR unifinder.js->on selection changed" ); + var SearchTree = document.getElementById( UnifinderTreeName ); - if( EventSelectionArray.length > 1 ) - { - //get all the rows for the events - for( i = 0; i < EventSelectionArray.length; i++ ) - { - var RowToScrollTo = SearchTree.eventView.getRowOfCalendarEvent( EventSelectionArray[i] ); - } - //select all the rows in the tree. + /* The following is a brutal hack, caused by + http://lxr.mozilla.org/mozilla1.0/source/layout/xul/base/src/tree/src/nsTreeSelection.cpp#555 + and described in bug 168211 + http://bugzilla.mozilla.org/show_bug.cgi?id=168211 + Do NOT remove anything in the next 3 lines, or the selection in the tree will not work. + */ + + SearchTree.treeBoxObject.selection.selectEventsSuppressed = true; + SearchTree.onselect = null; + SearchTree.removeEventListener( "select", unifinderOnSelect, true ); + + if( EventSelectionArray.length > 1 ) + { + //SearchTree.treeBoxObject.selection.selectAll( ); + } + else if( EventSelectionArray.length == 1 ) + { + var RowToScrollTo = SearchTree.eventView.getRowOfCalendarEvent( EventSelectionArray[0] ); - } - else if( EventSelectionArray.length == 1 ) + if( RowToScrollTo != "null" ) { SearchTree.treeBoxObject.selection.clearSelection( ); - - var RowToScrollTo = SearchTree.eventView.getRowOfCalendarEvent( EventSelectionArray[0] ); - + SearchTree.treeBoxObject.ensureRowIsVisible( RowToScrollTo ); SearchTree.treeBoxObject.selection.timedSelect( RowToScrollTo, 1 ); } } - gCalendarEventTreeClicked = false; + /* This needs to be in a setTimeout */ + setTimeout( "resetSelection()", 1 ); } } gCalendarWindow.EventSelection.addObserver( unifinderEventSelectionObserver ); } +function resetSelection() +{ + /* + Do not change anything in the following lines, they are needed as described in the + selection observer above + */ + var SearchTree = document.getElementById( UnifinderTreeName ); + + SearchTree.treeBoxObject.selection.selectEventsSuppressed = false; + + SearchTree.addEventListener( "select", unifinderOnSelect, true ); +} + /** * Observer for the calendar event data source. This keeps the unifinder * display up to date when the calendar event data is changed @@ -243,6 +259,8 @@ function getCalendarEventFromEvent( event ) function unifinderOnSelect( event ) { + dump( "\n\nin unifinder onselect" ); + var ArrayOfEvents = new Array( ); gCalendarEventTreeClicked = true; @@ -660,7 +678,7 @@ calendarEventView.prototype.getRowOfCalendarEvent = function( Event ) if( this.eventArray[i].id == Event.id ) return( i ); } - return( false ); + return( "null" ); }