Menu

#10 Need to support modal windows/dialogs

open
General (11)
8
2007-10-23
2007-10-23
Syd Logan
No

Trixul currently does not support modal windows. The main API for this could be one of two things: Modify the openDialog() JS method to support a modal flag. Or, in the window tag, support a modal=[true|false] attribute (which would be overridable by the modal flag on the openDialog() JS method, if specified).

This should translate to the Window abstract class representing the attribute, regardless of how it was specified, and the attribute being passed down to the concrete class that creates and displays the window.

In Cocoa, we might respond to a show request with code like this:

- (int) runModal
{
active = YES;
[NSApp runModalForWindow: self];
[self orderOut: self];
return result;
}

In Gtk+, we can use gtk_set_modal() to make the window modal.

A similar strategy is expected for .NET, though it may be the case that one must instantiate a different widget than what is used by Gtk+ and Cocoa.

Which implies another option -- we can introduce a new widget, e.g., Dialog, that can be used instead of Window to create a dialog. My tendency is to think that there is little need for such a distinction.

Another thing that needs to be considered is managing the lifetime of the dialog, and obtaining its result. An onclose() handler (a separate bug has been filed on this) can be used to allow (or disallow) the dismissal of a dialog.

Finally, we need to be able to retrieve the "value" of the dialog. Typically, this is done by telling the caller what button was pressed to dismiss the dialog. Examples: "yes", "cancel", "apply", "no". My thinking is that instead of hardcoding some fixed button categories, we can simply return the ID attribute of the button to the caller. This would allow the caller all that is needed to perform this sort of communication without restricting the developer to some fixed notion of the kinds of dialogs possible in Trixul.

Discussion


Log in to post a comment.