How to open a dialog in modal-mode - xul

What's the correct method, to open up a new dialog so that the user cannot return to the main window until the modal dialog is closed.
A typical modal window is created by the alert() function.
I've tried it like this without success:
.openWindow(null, "chrome://myapp/content/mywindow.xul","mywindow",
"chrome,centerscreen,all,modal",null);

You forgot to mention that you are using nsIWindowWatcher.
For the window to be modal you need to specify which window it needs to be modal to. If the first parameter to your openWindow() call is null then the window watcher won't know which window opened the dialog (which window needs to be suspended until the dialog is closed). In other words:
watcher.openWindow(mainWin, "chrome://myapp/content/mywindow.xul", "mywindow",
"chrome,centerscreen,all,modal", null);
Or simpler:
mainWin.openWindow("chrome://myapp/content/mywindow.xul", "mywindow",
"chrome,centerscreen,all,modal");
See window.openDialog().

Related

Access WebView2 newly opened window

If I run window.open("url") it will open url in new popup window, even if it is Edge WebView2. It will just have default Windows title-bar, and read-only url bar. I need to open url from WebView exactly in new popup window, via window.open("url").
Is there any way to access that window from my program as far as original WebView2 child-window? By accessing I mean injecting scripts, and getting js-response after injecting.
Or, at least, perhaps there is way to open url with some pre-injected script, like window.open("http://google.com -javascript: alert(5)")?
Update
Found MSDN article, probably this is what do I need. Trying to understand that.
Yes, the ICoreWebView2::add_NewWindowRequested event lets you intercept WebView2 opening new windows.
If you do nothing in the event handler, or don't subscribe to the event, you'll get a new popup like you describe. In script the return value of window.open is connected up to the newly opened popup window. But in your native code you have no access to or control over the newly opened window.
Or you can set the Handled property to true on the NewWindowRequested event's args, and no new window will be created. This is useful if you want to prevent opening windows or if you want to send new window opens to the default browser or somewhere else. In script the return value of window.open is null.
Or you can provide your own ICoreWebView2 via the NewWindow property. In this case you are responsible for and get to choose how to host that ICoreWebView2 in some manner. The ICoreWebView2 you provide as the NewWindow will be the target of the new window navigation and connected back up via script to the return value of the window.open call.
Because obtaining a new WebView2 may require asynchronous method calls, you can use the GetDeferral method on the event args to stop the completion of the window requested event until you call Complete on the deferral asynchronously later.
You can see a working sample of the add_NewWindowRequested event in our sample app.

Intellij toolwindow close/open or show/hide programatically

I have used the Intellij's tool window as the main frame. On click of a button from the same window, another window (jdialog) opens. When the jDialog box opens, i want to hide or close the tool window. And when the user clicks the stop button in the jDialog box, I want the tool window to appear again.
I have tried to set the visible property to false, like
toolWindow.getComponent().setVisible(false);
This just hides the content, but not the tool window itself.
Can you please suggest me a way to achieve this.
This is how you show/active it:
toolWindow.activate(null);
so hide could be like this:
toolWindow.hide(null);
and close like this:
ContentManager contentManager = toolWindow.getContentManager();
contentManager.removeAllContents(true);
contentManager.dispose();
(but I have not tried it :))

Modal dialog box disable main window

I'm open a modal dialog box using the next code:
call screen 0010 starting at 15 1.
However it disables the main window to continue working.
It's posible to call a modal dialog box and enable the main window to work while it's opened?
The very nature of a modal window is that it blocks the application until it is closed. The opposite would be an amodal dialog, and no, you can't have an amodal modal window. What you can do:
CALL FUNCTION 'Z_FUNCTION_WITH_DIALOG' STARTING NEW TASK 'FOOBAR' - this will start an additional external session (as long as the user has not exceeded the session limit).
Use the class CL_DGUI_DIALOGBOX_CONTAINER to produce an amodal window. Be aware that you can't use screens (dynpros) inside this container. Check the report RSDEMO_DIALOGBOX_CONTROL for some example coding.

Passing Gtk::Window& parameter to Gtk::MessageDialog

I have a function in gtkmm in the main window which opens a message box on the Help->About selection. The function is as follow:-
bool Main_window::on_about_selected(GdkEventButton *f_event)
{
Gtk::MessageDialog dialog(*this, "Msg Box example");
// left the rest
dialog.run();
}
this pointer passes the Main_window since it calls the function.
How should i pass this argument when i want to call a message box dialog from another file other than the Main_window?
How do i set parent of this message dialog to be the window on which i want this to be called?
how do i get the top level window?
That Gtk::Window is the transient-for (or parent) window, which associates the dialog window with a previously-open window.
If you want the dialog to have your main window as it's parent, you'll need to create some way to get that pointer to the main window. In an application, it's usually OK to just store it in a global variable. If it's not that simple for you, you'll need to invent your own system.
Calling Gtk::Widget::get_toplevel() on a child widget that you know about might help, but I suspect that it's not that simple. In particular, you'd have to be sure to only call it when you know that the child widget is really in a Gtk::Window.

Modal Window Problem

I am using modal window for my VB.NET program and i am trying to open this child modal window from another window, afte i close the child modal window i am trying to refresh the parent but i am getting retry/cancel popup, i tried a lot of things to avoid but i can't get rid of this popup :-( is there any way i can avoid this popup? I would really appreciate your help
Thanks
Faisal
Did you tried to bind an OnClickClient javascript function to the button who close the modal popup to manually call a PostBack to the server ?
function fnClickOK(sender, e) {
__doPostBack(sender,e);
}
that's the function you must include in your code and you can bind the button in the code behind like that
yourButton.OnClientClick = String.Format("fnClickOK('{0}','{1}')", yourButton.UniqueID, "");
Like that, the postback should occur and because of the page reload all Modal will be hided.
Good Luck!