Hello everyone,
got bit of a tickler here…
I have two controls warring for focus and I’m not sure how to get all my cake and eat it too.
Given that the cake is a lie, I present you with this conundrum:
$syncHash.OutputTextbox.Add_TextChanged({ $syncHash.OutputTextbox.SelectionStart=$syncHash.OutputTextbox.Text.Length $syncHash.OutputTextbox.ScrollToCaret() $syncHash.OutputTextbox.Focus() })
I also have this:
$syncHash.window.add_KeyDown({ param( [Parameter(Mandatory)][Object]$sender, [Parameter(Mandatory)][Windows.Input.KeyEventArgs]$e ) if($e.Key -eq 'Enter'){ $syncHash.Window.Dispatcher.invoke("Background",[action]{$syncHash.OutputTextBox.AppendText((Send-RTCmd|Out-String))}); $syncHash.InputTextBox.Focus(); } })
I just added the set focus to the Input which pretty much capped the finishing touches on this application only to have the output textbox no longer scroll to the bottom.
I tried chaining the commands so that the enter key had all the Output textbox event commands first, and the input textbox focus last, but that didn’t seem to work. The cursor ended up in the input textbox ( which is fine ) but it didn’t scroll the output to the end.
I also tried leaving out the focus command from the output, deciding it wasn’t necessary - it is, or seems to be according to my testing.
Suggestions?
Thank you