That code works just fine for me - creates a new device right after the track’s vol/pan device and then selects that device, no “delay” needed. The keyboard focus stays on the pattern editor, though, which I think is not what you want.
just_inserted_tool is a renoise.TrackDevice, renoise.song().selected_device_index is a number, so the assignment on line 2 throws an error. Additionally, the renoise.song().selected_device property is read-only, so I don’t think there’s a way to set the selected device with the actual renoise.TrackDevice object.
I’d love for there to be. Being able to set keyboard cursor focus to Disk Browser would be amazing, especially since discovering that left+right control which sample is chosen in the sample_keyzone_mode, and pressing enter on a sample in disk browser loads the sample to selected keyzone slot.
However, the cursor focus will only show in trackdsp view (lower frame) if the cursor focus is already on trackdsp…
So it’s half-working… And we return back to “Cursor Focus for Upper Frame & Lower Frame” setting