The first issue seems to be a Logic bug where automation is only recorded if there’s a short delay between the calls to beginGesture, setValue, and endGesture. There’s some discussion of the issue in this thread.
For the second issue, you could call setWantsKeyboardFocus (false) on your toggle button.
