Skip to content

Instantly share code, notes, and snippets.

@OliverM
Created Sep 4, 2011
Embed
What would you like to do?
responders in sproutcore
// ==========================================================================
// Project: ResponderTest
// ==========================================================================
/*globals ResponderTest */
ResponderTest = SC.Application.create({
NAMESPACE: 'ResponderTest',
VERSION: '0.1.0',
trace: YES
});
ResponderTest.statechart = SC.Object.create(SC.StatechartManager, {
trace: true,
initialState: 'begin',
begin: SC.State.design({
testAction: function(){
console.log('test action from button received.');
return NO; // pretend action not handled
}
})
});
ResponderTest.mainPage = SC.Page.design({
mainPane: SC.MainPane.design({
// defaultResponder: 'ResponderTest.statechart',
childViews: 'buttonView'.w(),
trace: YES,
buttonView: SC.ButtonView.design({
layout: { centerX: 0, centerY: 0, width: 200, height: 36 },
textAlign: SC.ALIGN_CENTER,
tagName: "h1",
title: "Welcome to SproutCore!",
action: 'testAction'
})
})
});
ResponderTest.main = function main() {
ResponderTest.getPath('mainPage.mainPane').append() ;
ResponderTest.statechart.init();
SC.RootResponder.responder.set('defaultResponder', 'ResponderTest.statechart');
};
function main() { ResponderTest.main(); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment