-
hey - I'm happy with your platform, it's been great to port a Winforms mono app to a CLI with .Net 7. My question is two-part, which is probably related to each other...
`
` And in the settings window, I'm closing the application with...
Is the unusual behavior of the TextView happening because I'm using the Application? Run<>() to open the settings window. What other facility does your platform have for opening another fullscreen window and waiting for a user response? Or should I switch to using events for the Settings window's cancel/save? Also, another strange behavior when I use the Application.Run(window) is with MessageBox dialog popups. In the secondary window (i.e. settings window), the first time a MessageBox.Query is called, the window goes away, and the parent window is shown with the message box. With these strange behaviors, I have to assume that I'm opening a secondary fullscreen window incorrectly. Unrelated stuff to my question. There are a few other things that I've done. I see the mention of requiring to Invoke for different threads, and there is no InvokeRequired(), so I created this for MainLoop...
` I also found ListView and ComboBox limiting because there are duplicate references. So since the GUI objects are lifetime instances, they should own the data. In which case, I added these. Of course, the source needed to be changed from private to internal. But I wanted to make only a few changes to your code on my end, so it'll be easier to update with your new releases. ListView2 namespace Terminal.Gui { internal class ListView2 : ListView {
} ComboBox2 namespace Terminal.Gui { internal class ComboBox2 : ComboBox {
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Awesome! glad to hear it! I'm pleased you are able to make headway using the library.
Yup that is the way to do it! The Dialogs example Scenario contains some code that does. Alternatively you might want to look at RunColumnWidthDialog in TableEditor.cs Scenario which runs a modal popup to illicit user input and then passes that back to rest of the program.
Instead I would recommend trying Note that
This is correct. Terminal.Gui does not throw on cross thread access but typically you will have unexpected side effects or things stop working. So I always just use MainLoop Invoke when updating from Tasks/Threads and let Terminal.Gui handle it. There should be no side effects from invoking when already on the UI thread other than code readability. If you anticipate hundreds of events a second or even just as good practice you may want to update your datastructures in real time but just use Task.Run(() =>
{
process.Start();
while (!process.StandardOutput.EndOfStream)
{
var line = process.StandardOutput.ReadLine().Trim();
lock(lockList)
{
consoleOutput.Insert(0,line);
Application.MainLoop.Invoke(()=>_results.SetNeedsDisplay());
}
}
});
} Updating a List (consoleOutput) and setting needs display - Source Code
Sorry, I'm not sure what you mean by 'duplicate references'? For the code you have provided, are you able to reformat it as a diff or describe the changes at a higher level and why they were necessary. Understanding the limitations of current views is important so it would be good to get your insight here. |
Beta Was this translation helpful? Give feedback.
-
Another suggestion to reuse data between windows is using a toplevel with If you don't want to use |
Beta Was this translation helpful? Give feedback.
Awesome! glad to hear it! I'm pleased you are able to make headway using the library.
Yup that is the way to do it! The Dialogs example Scenario contains some code that does.
Alternatively you might want to look at RunColumnWidthDialog in TableEditor.cs Scenario which runs a modal popup to illicit user input and then passes that back to rest of the program.
TextView
is more of a text …