-
Notifications
You must be signed in to change notification settings - Fork 695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MessageBox not closing in PowerShell #885
Comments
How you are calling the Msg class? You don't need to use |
This is not meant to be useful yet, just a test 😊
This is how I call it:
PS> import-module .\fwTextGUI.dll
PS> [fwTextGUI.Msg]::new("Test Message")
Alternately, you can call it directly with the same result:
PS > import-module .\Terminal.Gui.dll
PS > import-module .\NStack.dll
PS > [Terminal.Gui.Application]::Init()
PS > [Terminal.Gui.MessageBox]::Query(20, 10, "Test", "Hello World", "Yes", "No")
|
I don't know what you have in fwTextGUI.dll module. Try putting Since you call |
A little sample: static class Program {
public static void Main ()
{
Application.Init ();
var msg = new Msg ("Test Message!");
msg.Response = (e) => {
if (e == 0) {
Console.Write ("Yes");
} else {
Console.Write ("No");
}
// Exit
Application.RequestStop ();
};
Application.Top.Ready = () => msg.DisplayMsg ();
Application.Run ();
msg.Dispose ();
}
}
public class Msg : IDisposable {
string message;
public Action<int> Response;
public Msg (string message)
{
this.message = message;
}
public void DisplayMsg ()
{
var msg = MessageBox.Query (20, 10, "Test", message, "Yes", "No");
Response?.Invoke (msg);
}
public void Dispose ()
{
Console.Write ("\u001b[?1h");
}
} |
Yes, I've gotten it to work with a console application, but it won't work from within PowerShell. End goal is to write a PowerShell CmdLet that uses the Terminal.Gui API. Calling the MessageBox class directly from PowerShell using the alternative method outlined above fails (as well as using the simple single class DLL I had in my original post). |
@domhnal you may want to look at our ConsoleGuiTools project which exposes an |
Yes, I was looking at that yesterday, and that is ultimately where I'm headed, but my first example program left me scratching my head. I've done some debugging and it's not that the application hangs, output will continue to be printed to the screen, it's just that any new output is obscured by the modal message box. I can type 'exit' and the PowerShell window will close, you will just never see anything but the Message Box up until the window closes, at which point you get a very brief glimpse of what was printed to the display. |
@domhnal try this please: public class Msg : IDisposable {
public Msg (string Message)
{
Application.Init ();
var msg = MessageBox.Query (20, 10, "Test", Message, "Yes", "No");
Application.Shutdown ();
}
public void Dispose ()
{
Console.Write ("\u001b[?1h");
}
} |
OK, That worked. Mouse support doesn't work in the new windows terminal app, but works fine in the standard powershell 7 console. Thank you for your help. |
I still don't understand how that gap in mouse functionality still persists in the new Windows Terminal. |
Since this is a gui.cs<->Powershell issue/discussion.... I spiked a possible powershell integration for gui.cs at https://github.com/wgross/gui.ps1. |
@wgross I only managed to get it to work by changing the |
Me either: I guess they are working on it. This is tracked here: #332 |
First time user. I have a simple class created to display a Message box.
When I use the class from within PowerShell, the MessageBox opens but does not disappear once a option is chosen. What am I missing?
The text was updated successfully, but these errors were encountered: