mo.notono.us

Friday, September 24, 2004

Infragistics.Win tip: Determining if the mouse is over an element

For some reason best known to themselves, the developers at Infragistics didn't think to include a double click event for specific elements like rows or nodes (in the UltraWinGrid and UltraWinTree classes, respectively).

The hack I've resorted to to fix this looks like this:

/// <summary>Determines whether the mouse is over a node.</summary>
/// <returns><c>true</c> if the mouse if over a node; otherwise, <c>false</c>.</returns>
private bool IsMouseOverNode()
{
	bool result = false;
	try
	{
		Infragistics.Win.UIElement uiElem = 
			tree.UIElement.ElementFromPoint(tree.PointToClient(UltraTree.MousePosition));
		Infragistics.Win.UIElement nodeUIElem = 
			uiElem.GetAncestor(typeof (Infragistics.Win.UltraWinTree.TreeNodeUIElement));
		result = (nodeUIElem != null);
	}
	catch
	{}
	return result;
}
where tree is my Tree control instance. For a Grid, replace the guts with the following:
		Infragistics.Win.UIElement uiElem =
			UltraGrid.DisplayLayout.UIElement.ElementFromPoint(ultraGrid.PointToClient(CompositeGrid.MousePosition));
		Infragistics.Win.UIElement rowUIElem = 
			uiElem.GetAncestor(typeof (Infragistics.Win.UltraWinGrid.RowUIElement));
		result = (rowUIElem != null);

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home