[Mono-bugs] [Bug 414963] New: [REGRESSION] ListBox: SelectedIndexChanged event are duplicated

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Aug 6 04:59:02 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=414963


           Summary: [REGRESSION] ListBox: SelectedIndexChanged event are
                    duplicated
           Product: Mono: Class Libraries
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Windows.Forms
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: andyhume32 at yahoo.co.uk
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


As first noticed in bug 398341, events from ListBox on selected item change are
duplicated.  Looking back at 1.9 I don't see this fault, so 'regression'.

Repro, app ListBoxHarness.cs attached -- includes new buttons to do
programmatic access to the SelectedIndices collection.


* 'One' selection mode.
1. Select 'One' selection mode (MultiColumn mode on and off seems unimportant).
2. Click on ListBox items a, b, and c in turn each should be selected in turn.
Expect events:
   changed lb.SelectedIndex: 0, indices: '0'
   changed lb.SelectedIndex: 1, indices: '1'
   changed lb.SelectedIndex: 2, indices: '2'
But was!:
   changed lb.SelectedIndex: 0, indices: '0' , (lb.FocusedItem: 0)
   changed lb.SelectedIndex: 0, indices: '0' , (lb.FocusedItem: 0)
   changed lb.SelectedIndex: 1, indices: '1' , (lb.FocusedItem: 1)
   changed lb.SelectedIndex: 1, indices: '1' , (lb.FocusedItem: 1)
   changed lb.SelectedIndex: 2, indices: '2' , (lb.FocusedItem: 2)
   changed lb.SelectedIndex: 2, indices: '2' , (lb.FocusedItem: 2)
Each event is doubled!


* 'MultiSimple' Selection mode:
1. Select MultiSimple selection mode (MultiColumn mode on and off seems
unimportant).
2. Click on ListBox items a, b, and c in turn (all three should be selected). 
Then click item 'a' again to unselect it.
Expect events:
   changed lb.SelectedIndex: 0, indices: '0'
   changed lb.SelectedIndex: 0, indices: '0, 1'
   changed lb.SelectedIndex: 0, indices: '0, 1, 2'
   changed lb.SelectedIndex: 1, indices: '1, 2'
But see!
   changed lb.SelectedIndex: 0, indices: '0' , (lb.FocusedItem: 0)
   changed lb.SelectedIndex: 0, indices: '0' , (lb.FocusedItem: 0)
   changed lb.SelectedIndex: 0, indices: '0, 1' , (lb.FocusedItem: 1)
   changed lb.SelectedIndex: 0, indices: '0, 1' , (lb.FocusedItem: 1)
   changed lb.SelectedIndex: 0, indices: '0, 1, 2' , (lb.FocusedItem: 2)
   changed lb.SelectedIndex: 0, indices: '0, 1, 2' , (lb.FocusedItem: 2)
   changed lb.SelectedIndex: 1, indices: '1, 2' , (lb.FocusedItem: 2)
   changed lb.SelectedIndex: 1, indices: '1, 2' , (lb.FocusedItem: 0)
Each event is doubled!


* 'MultiExtended' Selection mode:
Is still broken due to bug 398341.  So not worth documenting the Mono behaviour
here -- see some example events logging in that bug.
Perhaps that mode needs fixed before this, as its selection events are the most
complex.


* 'None' Selection mode
Is ok:
   changed lb.SelectedIndex: -1, indices: '' , (lb.FocusedItem: 0)
   changed lb.SelectedIndex: -1, indices: '' , (lb.FocusedItem: 1)
   changed lb.SelectedIndex: -1, indices: '' , (lb.FocusedItem: 2)



The cause becomes apparent when "show event stack traces" mode is enabled. 
Some of the events come directly from the Control events and some via the
SelectedIndexCollection (and from the mouse up and down events respectively). 
See the full stack traces of the events below.  Note that the first instance
is:
   OnMouseDownLB -> set_SelectedIndex -> SelectedIndexCollection.Add ->
ListBox.OnSelectedIndexChanged
And the second is:
   OnMouseUpLB -> OnItemClick -> OnSelectedIndexChanged

Note that in MSFT selection changes are reported on Mouse *Up* (hold down the
mouse down on click, see no event; release, do see the event).


Full event stack traces:
[[
changed lb.SelectedIndex: 0, indices: '0' , (lb.FocusedItem: 0)
   at ListBoxHarness.GetState(System.Windows.Forms.ListBox lb)
   at ListBoxHarness+<ShowForm>c__AnonStorey0.<>m__0(System.Object ,
System.EventArgs )
   at System.Windows.Forms.ListBox.OnSelectedIndexChanged(System.EventArgs e)
   at System.Windows.Forms.ListBox+(Int32 index)
   at System.Windows.Forms.ListBox.set_SelectedIndex(Int32 value)
   at System.Windows.Forms.ListBox.OnMouseDownLB(System.Object sender,
System.Windows.Forms.MouseEventArgs e)
   at
System.Windows.Forms.Control.OnMouseDown(System.Windows.Forms.MouseEventArgs e)
   at System.Windows.Forms.Control.WmLButtonDown(Message ByRef m)
   at System.Windows.Forms.Control.WndProc(Message ByRef m)
   at System.Windows.Forms.ListBox.WndProc(Message ByRef m)
   at System.Windows.Forms.Control+ControlWindowTarget.OnMessage(Message ByRef
m)
   at System.Windows.Forms.Control+ControlNativeWindow.WndProc(Message ByRef m)
   at System.Windows.Forms.NativeWindow.WndProc(IntPtr hWnd, Msg msg, IntPtr
wParam, IntPtr lParam)
   at System.Windows.Forms.XplatUIWin32.InternalWndProc(IntPtr hWnd, Msg msg,
IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.XplatUIWin32.Win32DispatchMessage(MSG ByRef )
   at System.Windows.Forms.XplatUIWin32.DispatchMessage(MSG ByRef msg)
   at System.Windows.Forms.XplatUI.DispatchMessage(MSG ByRef msg)
   at System.Windows.Forms.Application.RunLoop(Boolean Modal,
System.Windows.Forms.ApplicationContext context)
   at
System.Windows.Forms.Application.Run(System.Windows.Forms.ApplicationContext
context)
   at System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm)
   at ListBoxHarness.ShowForm(Boolean multiColumnMode, SelectionMode
selectionMode)
   at ListBoxHarness.Main(System.String[] args)

changed lb.SelectedIndex: 0, indices: '0' , (lb.FocusedItem: 0)
   at ListBoxHarness.GetState(System.Windows.Forms.ListBox lb)
   at ListBoxHarness+<ShowForm>c__AnonStorey0.<>m__0(System.Object ,
System.EventArgs )
   at System.Windows.Forms.ListBox.OnSelectedIndexChanged(System.EventArgs e)
   at System.Windows.Forms.ListBox.OnItemClick(Int32 index)
   at System.Windows.Forms.ListBox.OnMouseUpLB(System.Object sender,
System.Windows.Forms.MouseEventArgs e)
   at
System.Windows.Forms.Control.OnMouseUp(System.Windows.Forms.MouseEventArgs e)
   at System.Windows.Forms.Control.WmLButtonUp(Message ByRef m)
   at System.Windows.Forms.Control.WndProc(Message ByRef m)
   at System.Windows.Forms.ListBox.WndProc(Message ByRef m)
   at System.Windows.Forms.Control+ControlWindowTarget.OnMessage(Message ByRef
m)
   at System.Windows.Forms.Control+ControlNativeWindow.WndProc(Message ByRef m)
   at System.Windows.Forms.NativeWindow.WndProc(IntPtr hWnd, Msg msg, IntPtr
wParam, IntPtr lParam)
   at System.Windows.Forms.XplatUIWin32.InternalWndProc(IntPtr hWnd, Msg msg,
IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.XplatUIWin32.Win32DispatchMessage(MSG ByRef )
   at System.Windows.Forms.XplatUIWin32.DispatchMessage(MSG ByRef msg)
   at System.Windows.Forms.XplatUI.DispatchMessage(MSG ByRef msg)
   at System.Windows.Forms.Application.RunLoop(Boolean Modal,
System.Windows.Forms.ApplicationContext context)
   at
System.Windows.Forms.Application.Run(System.Windows.Forms.ApplicationContext
context)
   at System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm)
   at ListBoxHarness.ShowForm(Boolean multiColumnMode, SelectionMode
selectionMode)
   at ListBoxHarness.Main(System.String[] args)
]]


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list