PDA

View Full Version : Adding to application launch event



Zavel
4 Mar 2012, 8:09 PM
In sencha designer 2, how can i add code to the application launch function?? Is this only possible by editing the JS files that get generated directly? If i edit the generated JS files, will sencha designer 2 be aware of and pick up those changes when i open it again or simply over-write them?

Thanks,
Shane

Zavel
4 Mar 2012, 8:11 PM
Sorry, i found it on the top left drop down in the code window..

aconran
5 Mar 2012, 5:25 AM
Sorry, i found it on the top left drop down in the code window..

We are working on some UI changes to make this more apparent.

worthlutz
5 Apr 2012, 5:29 AM
Where did this go? I could not find a way to get add items to application launch in build 360.

aconran
5 Apr 2012, 8:48 AM
Click on the Application node, in the bottom right property grid you'll see launch with a plus icon next to it. Click the plus icon and it will add a launch function.

worthlutz
5 Apr 2012, 10:59 AM
Thanks! I cannot keep track of what gets moved. Not complaining, just trying to keep up! I'm sure I'll get the hang of the system soon and be able to guess where to look.

Keep up the good work.

Worth

georgewr3
11 Apr 2012, 6:33 AM
I'm new to designer and ExtJS. Why does the previous version create a runnable version of a project without adding any manual code but this new version only adds an empty launch function? Or is that still in process?

aconran
11 Apr 2012, 8:51 AM
I'm new to designer and ExtJS. Why does the previous version create a runnable version of a project without adding any manual code but this new version only adds an empty launch function? Or is that still in process?

No, it should be working. Could you share a sample project with us? I'm sure you probably have some configuration problem.

georgewr3
11 Apr 2012, 9:42 AM
I just created a very simple project with a window which contains a container which contains a button. Everything is designer defaults.

I then selected the application node, clicked on the + next to launch and the center content window changed to an empty launch function.

Here is the code it generated (with comments removed and the full paths added for each file). I didn't edit any code. I'm sure I'm doing something wrong but I'm not sure what.


// PrjRoot/app/view/Viewport.js
//
Ext.define('MyApp.view.Viewport', {
extend: 'MyApp.view.MyWindow',
renderTo: Ext.getBody(),
requires: [
'MyApp.view.MyWindow'
]
});




// PrjRoot/app/view/MyWindow.js
//
Ext.define('MyApp.view.MyWindow', {
extend: 'Ext.window.Window',


height: 250,
width: 400,
title: 'My Window',


initComponent: function() {
var me = this;


Ext.applyIf(me, {
items: [
{
xtype: 'container',
items: [
{
xtype: 'button',
text: 'MyButton'
}
]
}
]
});


me.callParent(arguments);
}


});




// PrjRoot/app.js
//
Ext.Loader.setConfig({
enabled: true
});


Ext.application({
views: [
'MyWindow'
],
autoCreateViewport: true,
name: 'MyApp',


launch: function() {


}


});




// PrjRoot/app.html
//
<!DOCTYPE html>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>testprj4</title>
<link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-4.0.2a/resources/css/ext-all.css"/>
<script type="text/javascript" src="http://extjs.cachefly.net/ext-4.0.2a/ext-all-debug.js"></script>
<script type="text/javascript" src="app.js"></script>
</head>
<body></body>
</html>

aconran
11 Apr 2012, 10:28 AM
Did you want something in the launch function?

Because you have set the Window as the initial view it will be created when the application launches. Windows don't show by default though. You probably want to turn on the autoShow configuration on the Window.

aconran
11 Apr 2012, 10:29 AM
A sensible thing for us to do would be to set the autoShow configuration to true when an Ext.Window is marked as the initialView.

georgewr3
11 Apr 2012, 10:43 AM
I see. I think the previous version (1.2.2) added a show line by default. Thanks for pointing that out.


Ext.Loader.setConfig({
enabled: true
});


Ext.application({
name: 'MyApp',


launch: function() {
Ext.QuickTips.init();


var cmp1 = Ext.create('MyApp.view.MyWindow', {
renderTo: Ext.getBody()
});
cmp1.show();
}
});