Opening the log from script steals focus from selected files

Found this while debugging a longer script, this is the reduced-to-the-max version.

  1. Select a few files
  2. Select INVERT will toggle between the selected und the unselected files
  3. Run the script
  4. Select INVERT will still toggle
  5. If open, close the log
  6. Un-comment the line and run the script again
  7. The files are still selected, but they have lost the focus. Select INVERT will not toggle. Focus can be regained by going to a different Lister and back.
  8. Select a few other files, leave the log open
  9. Run the script
  10. Select INVERT will toggle
  11. BTW, files selected via Select FROMSCRIPT are equally affected

Conclusion: see topic title.

function OnClick(clickData) {
    var cmd = clickData.func.command;
    var tab = clickData.func.sourcetab;
    cmd.deselect = false;
    // cmd.RunCommand('Set UTILITY=otherlog');
    DOpus.ClearOutput();

    for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {
        var item = e.item();
        DOpus.Output(item);
    }
}
<?xml version="1.0"?>
<button backcol="none" display="label" label_pos="right" textcol="none">
	<label>TestOpenLog</label>
	<icon1>#empty</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>function OnClick(clickData) {</instruction>
		<instruction>    var cmd = clickData.func.command;</instruction>
		<instruction>    var tab = clickData.func.sourcetab;</instruction>
		<instruction>    cmd.deselect = false;</instruction>
		<instruction>    // cmd.RunCommand(&apos;Set UTILITY=otherlog&apos;);</instruction>
		<instruction>    DOpus.ClearOutput();</instruction>
		<instruction />
		<instruction>    for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {</instruction>
		<instruction>        var item = e.item();</instruction>
		<instruction>        DOpus.Output(item);</instruction>
		<instruction>    }</instruction>
		<instruction>}</instruction>
	</function>
</button>

Seems OK when I try. Am I doing the right thing?

Yes. But you are cheating :wink:

By using a button. Please try again with a hotkey for INVERT.

I don't think hotkeys work at all when the log panel has focus. They go to the edit control instead. (e.g. Ctrl-A will select all text in the log panel, rather than all files in the file display.)

The log panel doesn't have the focus.

I tried a bit more and it became really strange: After running the script the Alt key seems to be in the state of pressed down! :crazy_face:

So hitting Ctrl-I becomes Alt-Ctrl-I which has nothing mapped to it and therefore won't work.

Enter however becomes Alt-Enter and the properties dialog pops up.

F4 becomes Alt-F4 and the Lister closes.

Same with other hotkeys that use Alt. Even screenshot programs act as if Alt-Print was pressed when only Print was.

Everything is fine if the log panel doesn't get opened or is already open.

Opening the log panel gives the panel focus.

The log itself doesn't have focus yet, but the first button in the panel does (the save icon in this case). If you push Tab you'll see where the focus is (approximately; it'll move to the next item).

With the Alt key thing, is Alt held down while the panel is opening? Windows is probably losing track of the key state in different windows/controls somehow. Tapping the key should fix that if it gets into that mode.