Context menu opens on unexpected item in LocalTreeView/RemoteTreeView (where you can accidentally delete wrong directory)
|Reported by:||er11||Owned by:|
|Component version:||Operating system type:||Windows|
|Operating system version:||7 Home Premium SP1|
Description (last modified by )
I am using Windows 7 and haven't tested this under other operating systems. This happened to me with stable release 3.7.3 and a build I did tonight from SVN.
When using the right mouse button to bring up the context menu in either the local or remote directory tree controls in FileZilla Client, if you drag from the highlighted folder over one that isn't highlighted and release the button, the non-highlighted folder will be the target of the context menu that pops up. Worse, if this happens with a remote directory and you choose to delete the directory, the warning dialog that comes up doesn't give the name of the directory to be deleted.
I took a look at src/interface/LocalTreeView.* and src/interface/RemoteTreeView.* as well as the wxTreeCtrl source from wxWidgets 2.8.12. The event handler for a context menu event in LocalTreeView/RemoteTreeView is passed a tree item ID by wxWidgets that corresponds to the current mouse cursor position when the right mouse button is released. This is apparently standard behavior for Windows, so it seems it's up to FileZilla to accommodate it.
I'm attaching a patch that solves the issue for me. It adds an event handler for right-button drag that sets a boolean variable to 'true' to indicate (when the button is released and OnContextMenu() is called) that the context menu should use the currently selected tree item instead of the one passed to it by wxWidgets. If no drag occurs, the variable is false and the context menu will use the tree item passed by wxWidgets. The variable is reset to false after each OnContextMenu() call.
I thought it might be sufficient to have OnContextMenu() always use the selected item instead of the one under the mouse pointer, but if that is done it does not find the correct item if a different folder than the one currently selected is right-clicked.