4

Getting this weird issue, not sure if it's just me, and I don't remember this happening before...

#r "PresentationFramework"
#r "PresentationCore"
#r "WindowsBase"
System.Windows.Window(
    Content = System.Windows.Controls.TextBox())
    .Show()

The window shows up, the TextBox shows up, but I can't enter any alphanumeric text unless I paste them in, only spaces. Same deal with RichTextBox.

On the other hand, it works just fine with ShowDialog(), which led me to suspect it might have something to do with the event pump, so I replaced fsi.EventLoop with a WPF one -- but that one won't even call Run() for whatever reason.

Edit: The "answer" on the other question uses Application.Run(), which is effectively the same thing as using ShowDialog() in that both are blocking calls. However, this decimates the utility of calling WPF from FSI. My question is specifically on using the TextBox controls without making a blocking call to show the window.

Rei Miyasaka
  • 7,007
  • 6
  • 42
  • 69
  • The thread that would be process input events is blocked (it's waiting for text input in the shell). You could try launching the window in a separate thread) – Just another metaprogrammer Apr 04 '18 at 05:23
  • @FuleSnabel I thought about that, but it captures spacebar, backspace, and everything else just fine. I can also hook onto `TextBox.KeyDown`, and sure enough, it's firing. – Rei Miyasaka Apr 04 '18 at 05:52
  • 2
    Possible duplicate of [Unable to enter text in WPF TextBox in F# FSI](https://stackoverflow.com/questions/20679125/unable-to-enter-text-in-wpf-textbox-in-f-fsi) – Funk Apr 04 '18 at 06:07
  • 2
    Gotta love this community's trigger-happy moderation. Vote to close perfectly in-line questions because it's a "duplicate" of a five year old question that never got fully answered and has a different requirement. – Rei Miyasaka Apr 04 '18 at 07:50
  • 2
    Do you think it is not a duplicate? – FoggyFinder Apr 04 '18 at 09:10
  • 1
    @FoggyFinder That question just wants a solution that'll work with a *blocking* call to open the window. I need a solution that'll let me continue working in FSI. – Rei Miyasaka Apr 04 '18 at 16:19

0 Answers0