1. #1
    Sencha User
    Join Date
    Mar 2008
    Posts
    65
    Vote Rating
    6
    rtweed is on a distinguished road

      0  

    Default Desktop: dynamically adding a new window

    Desktop: dynamically adding a new window


    I've scoured the examples and searched the forums but drawn a blank. I have the ExtJS Desktop working great, but all the windows are pre-defined via either desktop icons or the start menu. What about if one of those windows includes a button that, when clicked, should open a new window that also gets added to the list of open windows on the taskbar?

    I haven't seen any examples of this and I can't figure out how I'd go about doing it - how and where to define the new window and how to get it added to the desktop? I've tried a few things but without success.

    Also, would there be anything special about how such a window would be deleted once closed?

    If anyone can point me in the right direction and/or can point me at any examples, that should be enough to get me on my way again.

    Many thanks for any help.

  2. #2
    Sencha User
    Join Date
    Mar 2008
    Posts
    65
    Vote Rating
    6
    rtweed is on a distinguished road

      0  

    Default Found it!

    Found it!


    Ignore my original posting. I figured it out, based on the bogusWindow module logic. The key steps were (1) adding an id to the adhoc window module, eg:

    theDesktop.adhocModule = Ext.extend(Ext.app.Module, {
    id:'adhoc',
    etc etc

    (2) making sure this module was added to getModules

    (3) Open a new window using:

    var x = {} ;
    x.windowId="x2" ;
    x.text="Another Window" ;
    theDesktop.getModule('adhoc').createWindow(x) ;

    I now appear to be able to arbitrarily add windows as I wish! Fantastic!


    I assume this is an OK way to do it?

  3. #3
    Sencha User
    Join Date
    Mar 2008
    Posts
    65
    Vote Rating
    6
    rtweed is on a distinguished road

      0  

    Default One problem - any ideas?

    One problem - any ideas?


    OK one problem I've discovered with this approach. The adhoc window module appears to need to be added to the getModules list in order for it to be generally available, but this means that one instance appears on the start menu list. The best I've been able to achieve is to remove its text, icon and handler:

    theDesktop.adhocModule = Ext.extend(Ext.app.Module, {
    id:'adhoc',
    init : function(){
    this.launcher = {
    text:'',
    scope:this,
    windowId:windowIndex
    }
    },
    etc.....

    ...but this leaves an annoying "phantom" menu option on the start menu, albeit not doing anything. This isn't a show-stopper, but it would be nice to be able to get rid of it.

    Is there any way to get round this and suppress the first adhoc window instance from getting onto the start menu?

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    58
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    I don't really understand.. If you want a window, just instantiate a Window:

    Code:
    new Ext.Window({
        id: 'window_id', // MUST be unique
        title: 'New Window',
        height: 400,
        width: 600
    }).show();

  5. #5
    Sencha User
    Join Date
    Mar 2008
    Posts
    65
    Vote Rating
    6
    rtweed is on a distinguished road

      0  

    Default


    Thanks for that!

    Problem is that, yes, what you're suggesting adds a new window, but it's not a desktop window in the sense that it doesn't have a minimize and maximise button, and it's not added to the taskbar when it's instantiated.

    Can that functionality be added by simply adding extra properties etc to the new Ext.Window code you've suggested?

  6. #6
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    58
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Well,a tiny glance at the API docs will give you the minimizable and maximizable config options.

    I don't know about adding it to the taskbar, you'd have to look at the code to see if you can "register" Windows with it.

  7. #7
    Sencha User
    Join Date
    Mar 2008
    Posts
    65
    Vote Rating
    6
    rtweed is on a distinguished road

      0  

    Default


    Thanks Animal - your pointers have been very helpful.

    In fact with a small modification to App.js, I've been able to achieve what I wanted using the technique I've described, so the windows are all properly registered in the taskbar and exhibit the expected taskbar-related behaviour, but the "baseline" one no longer gets added to the start menu.

    With this in place I think I can now do everything I want! Awesome!!

  8. #8
    Sencha User
    Join Date
    Feb 2008
    Posts
    194
    Vote Rating
    -1
    hpet is an unknown quantity at this point

      0  

    Default


    Can you please share the modification to the app.js and the way you call/instantiate new windows? I am also playing around with this.

    Thank you.

  9. #9
    Ext User
    Join Date
    Sep 2007
    Posts
    8
    Vote Rating
    0
    smijw is on a distinguished road

      0  

    Default me too

    me too


    I too have looked through a ton of posts and line by line through the code but I still don't get it. I need to be able to dynamically add windows.

    I have the desktop working and popping up windows from the desktop shortcuts but I don't know how to correctly popup windows from those pages (i.e. show then in the taskbar as well). What do I put instead of an a href? What code should that call?

    When I tried the code above I keep getting the error...

    ms has no properties
    [Break on this error] for(var i = 0, len = ms.length; i < len; i++){
    App.js line 60

    What have you guys found since your last post that might help?

    Thanks in advance.

  10. #10
    Sencha User SachinJadhav's Avatar
    Join Date
    Jun 2008
    Posts
    43
    Vote Rating
    0
    SachinJadhav is on a distinguished road

      0  

    Question


    Hi,

    Even I am using a desktop application.

    I am looking for how exactly can we register my window to desktop application and that should
    have a same behaviour as that of desktop window.

    I am facing some error that states

    ms is null
    for(var i = 0, len = ms.length; i < len; i++){
    App.js line 60

    Please guide me appropriately.

    Thanks for your time.


    Thanks and Regards,
    SachinJadhav.