View previous topic :: View next topic |
Author |
Message |
cristi_ursachi
Joined: 07 Mar 2005 Posts: 11
|
Posted: Mon Mar 21, 2005 2:54 pm Post subject: How to right click=>node selected |
|
|
I want to select a node(row) on right click on node, can I? |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Mar 21, 2005 9:57 pm Post subject: |
|
|
To do this you would need to use the Widget framework to change the behaviour of the RowWidget class.
Derive a new class from RowWidget and override the OnMouse as follows:
Code: |
public class MyRowWidget : RowWidget
{
public MyRowWidget(Row row)
: base(row)
{}
public override void OnMouseDown(MouseEventArgs e)
{
OnLeftMouseDown(e);
if (e.Button == MouseButtons.Right)
{
OnRightMouseDown(e);
}
}
}
|
This will change the behaviour of the RowWidget so that the row is selected (which is the default behaviour of OnLeftMouseDown) even if the button pressed is the right button. If you want to have context menus then you still need to call OnRightMouseDown for right buttons.
Then you inherit from VirtualTree to override the method that creates the row widget as follows:
Code: |
using Infralution.Controls.VirtualTree;
public class MyVirtualTree : VirtualTree
{
protected override RowWidget CreateRowWidget(Row row)
{
return new MyRowWidget(row);
}
} |
_________________ Infralution Support
Last edited by Infralution on Tue Apr 05, 2005 8:59 am; edited 1 time in total |
|
Back to top |
|
|
cristi_ursachi
Joined: 07 Mar 2005 Posts: 11
|
Posted: Tue Mar 22, 2005 10:46 am Post subject: |
|
|
Thanks, it works |
|
Back to top |
|
|
MHB
Joined: 04 Apr 2005 Posts: 69
|
Posted: Mon Apr 04, 2005 3:34 pm Post subject: |
|
|
Since I only needed a context menu on right click, I added
Code: | SelectedRow = (Row) e.Row; |
to the GetContextMenu event handler (e is the GetContextMenuEventArgs) to obtain this.
It would be nice to have a property on the virtualtree to get this quite standardized behaviour. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Apr 04, 2005 11:02 pm Post subject: |
|
|
I'm not quite sure what you are asking to be standard behaviour - do you mean selecting the row on right click?
Regards
Grant Frisken _________________ Infralution Support |
|
Back to top |
|
|
MHB
Joined: 04 Apr 2005 Posts: 69
|
Posted: Tue Apr 05, 2005 10:52 am Post subject: |
|
|
Exactly! Like the behaviour in Windows Explorer. When an item is right clicked, the item is selected before showing a context menu.
The point is that I can't imagine a situation where I would want a context menu for an item without that item also beeing selected, in order to visualize the relation between the menu and the item. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Apr 05, 2005 10:32 pm Post subject: |
|
|
Explorers behaviour is not quite that simple. Consider the FileList on the right hand side when there are multiple items selected. Right clicking (with no modifiers over the selection) does not give the same behaviour as left clicking - because the selection is preserved. This is probably the desired behaviour - we will add it as a feature request. _________________ Infralution Support |
|
Back to top |
|
|
MHB
Joined: 04 Apr 2005 Posts: 69
|
Posted: Wed Apr 06, 2005 2:40 pm Post subject: |
|
|
True - multiple selection complicates the matter. I think the point is that the selection is only changed if the right click happens on an item that was not already selected.
There are also some related issues with dragging, both using right and left button. On a left click, the selection should not be changed until mouseup, and then only if a drag wasn't performed. It should also be possible to drag using the right button - again, if the right button is pressed on an already selected item, the selection should not be changed. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Apr 06, 2005 11:36 pm Post subject: |
|
|
The decision to apply selection on mouse down was deliberate (even though this is slightly different to Windows explorer). Windows explorer is somewhat inconsistent - it applies selection on mouse down if there are no modifers and on mouse up if there are.
We don't currently support drag using the right mouse button - why would you want to do this? _________________ Infralution Support |
|
Back to top |
|
|
MHB
Joined: 04 Apr 2005 Posts: 69
|
Posted: Fri Apr 08, 2005 10:11 am Post subject: |
|
|
I don't currently need right mouse drag, that was just a general suggestion
But I would certainly like to be able to left drag more than one row, and that seems impossible when mouse down selects. Windows explorer doesn't apply selection on mouse down if the item is already selected, exactly for this purpose (I suppose). |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri Apr 08, 2005 10:44 pm Post subject: |
|
|
You can drag rows without deselecting the current selection by holding the shift key down while you select. This isn't as convenient as just dragging - but this is somewhat difficult as you pointed out with selection action on mouse down. We will have a look at this for the next release and see what we can do.
The bindings and drag/drop mechanism only handle dragging a single row at this stage - we will have a look at handling multiple selections as well. _________________ Infralution Support |
|
Back to top |
|
|
MHB
Joined: 04 Apr 2005 Posts: 69
|
Posted: Mon Apr 11, 2005 8:56 am Post subject: |
|
|
Thanks, that's all I could ask! |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Apr 12, 2005 9:33 am Post subject: |
|
|
Version 1.4.0 has now been released. This adds selection on right mouse click as standard behaviour and enables drag and drop of multiple selections. See the release notes for details. _________________ Infralution Support |
|
Back to top |
|
|
MHB
Joined: 04 Apr 2005 Posts: 69
|
Posted: Tue Apr 12, 2005 2:56 pm Post subject: |
|
|
That was quick! Good service
I only have one problem: When I try to drag select (which is disabled, since it disables dragging) over an area that is not covered by a row, I get an ArgumentException in system.drawing.dll. I not sure whether this is new...
It would also be nice to have both drag select and drag'n'drop, but I know it's not obvious how to do that. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Apr 12, 2005 10:38 pm Post subject: |
|
|
Quote: | over an area that is not covered by a row |
Do you mean past the end of the tree content (at the bottom) or somewhere else?
We had thought that having drag selection AND drag and drop would be nice - but it isn't possible to do it using the same mouse interactions. We could potentially enable drag selection if some other modifier (eg Alt) is used if drag and drop is enabled - but this is probably too obscure for most users. _________________ Infralution Support |
|
Back to top |
|
|
|