HackPlan / quark-shell-mac

Quark Shell for Mac helps web developers to create native-like Mac menubar app using HTML and JavaScript without writing any native code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support multiple new windows

xhacker opened this issue · comments

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/4206266-support-multiple-new-windows?utm_campaign=plugin&utm_content=tracker%2F899498&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F899498&utm_medium=issues&utm_source=github).
commented

With this in mind, how do you envision the mw.close() function to work when multiple windows are at work ?

Do you want to pass some sort of id ?
var newWindowId = mw.newWindow();
var newWindowId2 = mw.newWindow();

mw.close(newWindowId);
mw.close(newWindowId2);

Ive managed to make the code popup 2 windows (just two variables with some simple logic), my next attemtp will be to use an array (or list) to keep track of the LDYWebViewWindowController windows.

@codewise-nicolas: we can do mw.newWindow("WindowID"); and mw.close("WindowID");

commented

Here is what I have so far, please excuse me as its my first work with objective-c.
It works great with no errors.
File LDYWebViewDelegate.m https://gist.github.com/codewise-nicolas/fb4f03f238d5015f0160
File LDYWebViewDelegate.h https://gist.github.com/codewise-nicolas/038a77c3f6103747e53a
File LDYWebViewWindowController.m https://gist.github.com/codewise-nicolas/dff930d42b9f02c0df1c
File LDYWebViewWindowController.h https://gist.github.com/codewise-nicolas/90d1e6644ee8cc9a8bc5

Apologoes for the gists, I will try and get a proper git repo going locally to track changes.

I store the webview into a NSMutableDictionary. The key is "name" parameter passed into the function call, mw.newWindow({name: 'a name'}), and mw.closeWindow({name: 'a name'});
I also updated the newWindow code so that if the window name already exists, then it doesnt re-instantiate but shows it (and goes to the url provided)
Also added code to trap the close event from the new window so we can remove it from the dictionary.