View previous topic :: View next topic |
Author |
Message |
billcch
Joined: 19 Jan 2007 Posts: 44
|
Posted: Sat Feb 24, 2007 1:57 am Post subject: determine if mouse down position is on the top of main colum |
|
|
How can I determine if mouse down position is on the top of main column icon. (I have some special context menu provides only for the row icon)
Thanks |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Sun Feb 25, 2007 10:36 pm Post subject: |
|
|
You can call VirtualTree.GetWidget(x, y) to retrieve the widget under the given mouse position. This will return a CellWidget if the mouse is over a column cell or a RowWidget if the mouse is over any other part of the row (including the row icon). The icon does not have its own widget - it is drawn by the RowWidget so that is as close as you can get. You'd have to calculate the offset yourself based on the row.Level.
A better way may be to create your own custom RowWidget (see the section in help on doing this) and override the OnMouseDown method. The RowWidget class has some internal methods (MainColumnX, IconOffset) that would allow you to determine whether the mouse down position is over the icon. The left position of the icon is given by:
Code: | x = MainColumnX + IconOffset |
_________________ Infralution Support |
|
Back to top |
|
|
billcch
Joined: 19 Jan 2007 Posts: 44
|
Posted: Mon Jul 06, 2009 5:41 pm Post subject: MainColumnX + IconOffset |
|
|
I upgrade my virtual tree to 3.12.1, since it removed
MainColumnX and IconOffset properties, not sure which is the best way to fix the following code.
Code: | int x = MainColumnX + IconOffset; |
Thanks! |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Jul 06, 2009 10:39 pm Post subject: |
|
|
These were removed because the CellWidget class is now responsible for drawing the Icon and connections. This overcomes the issue where setting the BackColor or BorderColor for the main column had a different visual effect to other columns. It also greatly simplifies the code.
To handle this you would need create a custom CellWidget instead of RowWidget and in your OnMouseDown method check whether the cell is for the main column like this:
Code: | if (this.Column == RowWidget.MainColumn)
{
int x = Bounds.X + IconOffset;
} |
where x gives you the left position of the icon as before _________________ Infralution Support |
|
Back to top |
|
|
billcch
Joined: 19 Jan 2007 Posts: 44
|
Posted: Tue Jul 07, 2009 2:53 pm Post subject: |
|
|
Thanks |
|
Back to top |
|
|
|