PDA

View Full Version : Newbie - event handling



themire
22 May 2007, 12:36 AM
Hi,

I want to respond to a regionresized event in a BorderLayout.
According to the documentation "

Subscribers will be called with the following parameters:
region : YAHOO.ext.LayoutRegion
newSize : NumberThe new size (width for east/west, height for north/south)
"


The problem is I can pick up the event ok but can't read the parameters passed. (I want the new size of the layout)

Here is my code for adding the listener.

layout.addListener("regionresized", myhandler = function(e) { alert(e['newSize']) });

Any help?

Animal
22 May 2007, 1:30 AM
Declare the parameters.



function(p1, p2, p3) { // I can access p1, p2 and p3, no more! }

themire
22 May 2007, 1:34 AM
Ok thanks,

How do I refer to the parameters though?

Should it be function(region, newSize) { alert(newSize); }

Or do you have it give it reference to an object?

Sorry, I couldn't find any documentation on event handling for ext.

rtannert2
22 May 2007, 4:32 AM
When I'm confused about usage, I typically search the library for examples, in the examples and source folders. If you do a quick search of the source for regionresized, you'll find it's used in BorderLayout.js and LayoutStateManager.js in just the way you're wanting to do. In these files .on is used in place of .addListener. However, you can use the anonymous function as you suggested in your last post, also.

If you read through some of the code in the examples folder, Ext event handling will quickly become clear, I think. Also, please have a look at Brian Moeskau's wonderful Intro to Ext (http://www.extjs.com/tutorial/introduction-ext) tutorial.

I don't think it matters in this case, but the documentation you quoted is from an earlier release of the library. You'll probably want to download the most recent release (http://www.extjs.com/download) for reference.

efege
22 May 2007, 5:29 AM
If you read through some of the code in the examples folder, Ext event handling will quickly become clear, I think. Also, please have a look at Brian Moeskau's wonderful Intro to Ext (http://www.extjs.com/tutorial/introduction-ext) tutorial.

I'm writing a tutorial on event handling in Ext. Well, at least on what I manage to understand about the topic. Feel free to make me feel some pressure, so I finish it soon :D