sender in MouseEvents

  • Thread starter Thread starter simonrigby_uk
  • Start date Start date
S

simonrigby_uk

Hi folks,

Small issue with sender argument in mouse events.

I have a container control that users can add instances to of a another
control at runtime. In response to the user adding a new control (Task)
to the container (Pad), I create a new instance of Task, add two
handlers, one for MouseUp and one for MouseDown and then add the Task
to Pad.Controls.

I then want the user to be able to link them by dragging from one to
the other, so the user MousesDown on one instance and MousesUp one
another.

If i quiz the sender argument in the MouseDown delegate and the MouseUp
delegate it seems that sender is always the instance that raised the
MouseDown. I have quizzed the hascodes of the sender as well as
declaring a private member of the Task when its created that just
records the time it was created.

Both instances of the Task control are unique (different hashcodes,
different private variable values, instanceA.Equals(instanceB) ==
False).

Its like the sender remembers the instance that raised the MouseDown.

Any help greatly appreciated.

Bonnie, if you read this, your help got me through making sure they
were unique instances but still the same problem.

Cheers

Simon Rigby
 
Extra thoughts to see if this helps anyone. Is it possible that the
first control clicked is getting the focus, then despite the fact that
cursor leaves that control and rests over another, for all intents and
purposes the first control still has the mouse focussed on it.

Cheers (this driving me nuts)!!!

Simon
 
Simon,

I think you want to use the Drag/Drop event stuff rather than the MouseDown,
MouseUp stuff. See if that helps ...

~~Bonnie
 
Hi Bonnie,

Thanks again. I had tried this before but made the mistake of
initiating the DragDrop in the client object. When I handled it in the
container, it worked perfectly.

Cheers

Simon
 
Back
Top