Mapping a resize event
I would like all my views to respond to a resize event. I have been able to do something like:
contextView.stage.addEventListener(Event.RESIZE, onResize);
and then pass that on to the dimensions to the view:
view.resize(width, height);
Similarly I managed to do it in the startupCommand the same way
except then mapping Event.RESIZE to the commandMap
and having the ResizeCommand class throw a resize event that the
entire project can listen for.
I feel like the latter is a better way but I am not sure if that is still the optimal solution. Does anyone have a good solution for this?
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Abel de Beer on 05 Feb, 2011 12:55 PM
If I had to choose from these 2 options, I would go for the first one, because in that case you don't need an extra Command and Event class.
The 'problem' is that a lot of the times you'll need to do extra calculations to scale and position your view components. For example, you need to take into account the initial stage sizes compared to the sizes you used for development. In that case in can be useful to have a StageService / StageManager class that does these calculations for you, and then have your mediators listen for events / signals from that class. The mediator can then request the corresponding values for that specific view. I chose this approach for my own project and it works very well.
Also, there's some more discussion on this topic on this forum already:
http://knowledge.robotlegs.org/search?q=stage+resize&t=d&sc...
Stray closed this discussion on 18 Feb, 2011 07:15 PM.