Author Topic: focus lost and copied item not selected when CTRL+C then CTRL+V  (Read 14616 times)

sickOfMS

  • Junior Member
  • **
  • Posts: 15
    • View Profile
portable multicommander v6.0 build 2118 x64
win 8.1

select any file and just hit CTRL+C then CTRL+V
current tab/panel becomes inactive (lost focus) and selected file is unchanged (except it is blue-pale i.e. as selected file in inactive panel).

I would really like to have newly pasted file as selected and other files that were selected before copy-paste to become deselected.
It would be perfect if this could be an option in settings.

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4386
    • View Profile
    • Multi Commander
Re: focus lost and copied item not selected when CTRL+C then CTRL+V
« Reply #1 on: April 04, 2016, 22:00:38 »
Problem with Ctrl+C / Ctrl+V is that Windows Explorer is handling the copy.
MC sends the command to Windows to "paste" what it has in clipboard and then Windows do it stuff.. But sometimes Windows fells like it want to steal the focus.
And since this is happening in the background. MC does not know when the copy is done or what happen.

There are a lot of issues (limitations) with using cut / paste to copy files.  How cut/ paste works in Windows is a really badly designed solution that still is the same as it was for Windows95. And it is so because of compability reasons..

« Last Edit: April 04, 2016, 22:08:23 by Mathias (Author) »

sickOfMS

  • Junior Member
  • **
  • Posts: 15
    • View Profile
Re: focus lost and copied item not selected when CTRL+C then CTRL+V
« Reply #2 on: April 04, 2016, 22:25:29 »
Others do this. You can 'steal' focus again, use timer or thread. Copy is already launched in thread, I guess, so just refocus to your panel few milliseconds after start or when copy is finished select pasted files (keep list before starting).
I am guessing but there must be the way everybody else does it, no? (I just tried in freecommander XE and explorer++.
CTRL+C then CTRL+V then arrow-up (or down) on keyboard and selection changes ... i.e. focus is back on panel where I was.

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4386
    • View Profile
    • Multi Commander
Re: focus lost and copied item not selected when CTRL+C then CTRL+V
« Reply #3 on: April 04, 2016, 22:45:43 »
No, Sorry, Would not work, You can't steal focus from a process without that process already given you permission to do that.
( The problem is that the other fm you mention is build on top on WinExplorer shell and they are hook into the Windows Shell a another way)
if MC would not do so much threading and block UI instead, then it might have worked.

But just keep refreshing is no ide. MC does not know when the copy is finished.  MC does not know if it was 1 file or 42 million
It have no idea when the copy is done. for MC it is a fire and forget action.   "They Windows the stuff in the clipboard, try to paste them to this location.  And also. check with all registered shell extension first if they want to handle them instead. Okey,.. Good.. bye"

sickOfMS

  • Junior Member
  • **
  • Posts: 15
    • View Profile
Re: focus lost and copied item not selected when CTRL+C then CTRL+V
« Reply #4 on: April 05, 2016, 16:38:56 »
Yes that was not really a good idea but ... here is another idea :)
Your panel auto-refreshes and redraws on each new item i.e. pasted file. So when you get that notification that there is a new item and you need to refresh the list then can't you do SetFocus to this where 'this' is your panel-list window? It's a child of your main app window so it should be fine ?

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4386
    • View Profile
    • Multi Commander
Re: focus lost and copied item not selected when CTRL+C then CTRL+V
« Reply #5 on: April 05, 2016, 16:48:10 »
Nope stealing focus from Windows does not work.  (Unless you hook your self into Windows and forces it. But that is a big no no.. It is not allowed)
Problem is that another app have taking focus from MC. (Windows or a ShellExtension)
And even I could steal focus. Doing it on when the filesystem is refreshed is bad.. It would make MC react weird.. It would make MC steal focus even if you was in another program that wrote a file to a location where MC was listing files.

However Windows did not steal focus like this before. Maybe something changed in windows. Maybe a Win10 issue. I don't know.



sickOfMS

  • Junior Member
  • **
  • Posts: 15
    • View Profile
Re: focus lost and copied item not selected when CTRL+C then CTRL+V
« Reply #6 on: April 05, 2016, 18:44:11 »
No, no, no you're not stealing focus from windows.
Your main app i.e. MC still has focus.
Do copy-paste file and then hit 'Alt' key ... you'll see that menu in MC will get underscored letters i.e. it'll act i.e. you can navigate and use your keyboard it's just that your child window of MC, which is in the end panel where the list of files, did lost focus. But you're still fine you're in MC so you can decide which window i.e. part of your UI you want to set focus to.
And as I said if you call SetFocus it is safe even if MC doesn't have focus and you call childOfMC->SetFocus(... then everything will still be fine Windows OS will not change focus, it will ignore you since your main app MC doesn't have focus. But in this copy-paste issue you're fine it will work.
It would take you only few minutes to call SetFocus inside you panel-list object that derives from CWnd (I guess it's the list UI element or something like that).
You don't have to call global windows ::SetFocus( but rather CWnd (parent) member i.e. this->SetFocus(

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4386
    • View Profile
    • Multi Commander
Re: focus lost and copied item not selected when CTRL+C then CTRL+V
« Reply #7 on: April 05, 2016, 19:42:27 »
I know. It is already calling setfocus.  but it is blocked or windows ignores it..


« Last Edit: April 05, 2016, 20:19:49 by Mathias (Author) »