Page 1 of 1

Standalone menubar with multiple documents

Posted: Sat Oct 25, 2008 11:20 pm
by trevix
There is something that I do not understand between standalone on Window and on OSX:
I have a RunRev standalone that opens different documents with the usual "open","Close","Save as".
On OSX, being the menu on the top of the screen, everything works as usual.
On Window, when I close the document, the menubar disappear, the application disappear from the task bar (but I can tell that is open looking at the TaskManager application...)
Does that means that I had to make a fake main stak and have the real stak as a substack, in order to keep some kind of menu ? (Gosh..I have do do it all over again). Or is there another solution ?
I noticed that on window some applications (like Word) keep the main window, changing its content; others, like RunRev, keep only a menubar if no stack is open.

Trevix

Posted: Sun Oct 26, 2008 9:59 am
by Mark
Hi Tevix,

I follow two different approaches, depending on the kind of programme I am making.

Often, I create a document template stack with a menubar. When I need a new document, I simply clone the template stack and it will have its own menubar.

If the interface has to be more complex due to more extensive funcionality, I might create a palette with a menubar and a toolbar, similar to that of revolution. Add a backdrop with a palette with status bar at the bottom and it looks like Word's main window.

When you close the last visible window of your application on Windows, you have to exit the standalone. You can do something like this:

Code: Select all

on closeStackRequest
  repeat for each line myStack in the openStacks
    if the visible of stack myStack then
      put myStack & cr after myVisibleStacks
    end if
  end repeat
  if number of lines of myVisibleStacks is not 0 then
    quitThisProject
  else pass closeStackRequest
end closeStackRequest
Keep in mind that checking the visibility may not be enough. This depends on your project. You can find the quitThisProject handler here:

http://runrev.info/Save%20Way%20to%20a%20Quit.htm

Best,

Mark

Posted: Sun Oct 26, 2008 10:06 am
by Janschenkel
Windows/Unix and Mac have traditionally had very different approaches, that confuse people coming in from the other platform. Mac users want their application to stay open even when all documents are closed, Windows/Unix users are used to everything disappearing when they close the last window of an application.

Windows introduced the concept of a Multiple Document Interface (MDI) where one giant window contains all windows of that application. What gets confusing about this approach as used in Word is that depending on the 'X' you click on, the whole application closes or just your document.

Ignoring the pros and cons of each approach, let's see how we can make your application behave correctly.

If you just want to make sure the application quits when the last window is closed, put the following into your stack script:

Code: Select all

on closeStack
  if the openStacks is the short name of this stack then
    -- this is the last open window so quit if not on MacOS
    if the platform is not "MacOS" then
      quit
    end if
  end if
end closeStack
If you want the Word-like approach, it gets a tad more complicated, as Revolution doesn't really have the concept of a window which contains other windows. One popular approach is to use only a single stack, and put your 'documents' in different tabs in the same window - similar to how quite a few Windows applications replaced the traditional MDI.

The Revolution IDE takes a Mac-like approach: there's a stack 'revMenubar' which contains the general menubar and toolbar, and unless a stack with its own menubar has the focus, this is what you see in your Mac menubar. But on Windows/Unix it's always there, as a separate window.

Jan Schenkel.