"Modal" Window Question

I have a small modal window that pops up when a user clicks on context menu on widget. The modal window shows up fine, but I was wondering if there was a way to “hide” or “darken” the rest of the screen. The focus is on the modal window, but I would like to have the user to also focus visually only the modal window. I saw in a couple of places e.g. ModalBox, My Yahoo where only the overlay modal window is focused, everything else is “darkened” and when the modal window is closed, the main screen is visible again.

thanks in advance.

I have done this in my application as follows:

Create the following canvas and either autodraw it in place (for me that is directly into the BODY of my HTML document).

isc.Canvas.create({
  ID: "modalScreen",
  width: "100%",
  height: "100%",
  backgroundColor: "black",
  opacity: 45,
  autoDraw: true,
  visibility: "hidden"
})

Then whenever you want to show a modal dialog/window you can call modalScreen.show(). When your dialog is dismissed, you can call modalScreen.hide().

For me, I extended isc.Window with the following properties:

  closeClick: function() {
    modalScreen.hide();            
    this.Super("closeClick", arguments);
  }

and

  show: function() {
    modalScreen.show();
    this.Super("show", arguments);
  }

Works for me, but YMMV.

  • david

Works (almost)

dharding,
Thanks for your response. I get the idea how to do it now. The only minor issue I have is that when the modal window overlays, the underlying SmartClient components (a Canvas and a TabSet) on the page still are visible (in background). The rest of the page is “grayed out”.

I am thinking I’ll get the ID of each of SmartClient component and call show() and hide() alternatively to achieve that effect. Is there any better way to do that? thanks again.

Hi Ninad,

Be sure to create the “modalScreen” component after anything else you want it to mask.

Ah, good point. I forgot to mention that important detail.

  • david

Oops. Switched browsers and my auto login changed accounts on me. Karmadillo is me (dharding).

  • david

Perfect (works like a charm)

By just moving the modalScreen canvas to the end of the page, it was able to hide all the SmartClient components too.
Thanks a ton guys.

Use winModal.setShowModalMask(true);