Skip to content

Instantly share code, notes, and snippets.

@OliverM
Created September 4, 2011 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OliverM/1192538 to your computer and use it in GitHub Desktop.
Save OliverM/1192538 to your computer and use it in GitHub Desktop.
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