Results 1 to 4 of 4

Thread: Sencha Architect 3.1 Button click handler in ViewController

  1. #1
    Touch Premium Member pmarko's Avatar
    Join Date
    Dec 2007
    Location
    Ireland
    Posts
    64

    Default Answered: Sencha Architect 3.1 Button click handler in ViewController

    Hi there,

    Can someone help me with the button handler issue please ?

    I have a container with bunch of buttons and I need all of them to hit same listener on click.

    Quick and dirty piece of cake:
    Code:
    {
    xtype: 'button',
    text: 'Button 1',
    handler: 'onButtonClick',
    myCustomProperty: 'button1'
    },
    {
    xtype: 'button',
    text: 'Button 2',
    handler: 'onButtonClick',
    myCustomProperty: 'button2'
    }
    Unfortunately not in architect.
    Button handler function can not be specified as string. Ups.
    And when I try to create "View controller Event Binding" with the same fn name it won't let me to do so.

    Any workaround ? Do I miss something ? Or how to create listener on container listening to all underlying buttons click event in ViewController and architect ?

    Thanks for help.

  2. Support for the 'handler' config resolving to a view controller method should be appearing in a near-future release. However, that won't solve the bigger issue which is that Architect currently does not support sharing handlers between multiple event listeners.

    We do recognize that pattern is often a useful one, so we do plan on investigating the possibility of enhancing Architect to allow it, but I can't say for sure if it will happen or how soon. There are definitely some complex issues around that which we'll have to work through; the current 1-to-1 assumption is relied upon for some of Architect's useful features, so we'd have to make sure that opening it up wouldn't break other things or make it less useful.

    In the meantime, you have a couple choices:

    A) Use the separate handlers for each button and have each handler just call another common method

    Use a Controller Action on the viewcontroller that targets all the buttons via selector, much like you would have done with the old global controller architecture

  3. #2
    Sencha User jjohnston's Avatar
    Join Date
    Sep 2010
    Posts
    567
    Answers
    30

    Default

    Support for the 'handler' config resolving to a view controller method should be appearing in a near-future release. However, that won't solve the bigger issue which is that Architect currently does not support sharing handlers between multiple event listeners.

    We do recognize that pattern is often a useful one, so we do plan on investigating the possibility of enhancing Architect to allow it, but I can't say for sure if it will happen or how soon. There are definitely some complex issues around that which we'll have to work through; the current 1-to-1 assumption is relied upon for some of Architect's useful features, so we'd have to make sure that opening it up wouldn't break other things or make it less useful.

    In the meantime, you have a couple choices:

    A) Use the separate handlers for each button and have each handler just call another common method

    B) Use a Controller Action on the viewcontroller that targets all the buttons via selector, much like you would have done with the old global controller architecture
    Jason Johnston
    @lojjic
    Sencha Architect Development Team

  4. #3
    Touch Premium Member pmarko's Avatar
    Join Date
    Dec 2007
    Location
    Ireland
    Posts
    64

    Default

    Thank you very much for answer.

    I went the B way as the buttons are coming from database config.

  5. #4

    Default

    When will this be available in Architect as this is really a problem since I want all my functions in the ViewController, so currently the handler on buttons I cannot use string to fire function in ViewController:

    "Support for the 'handler' config resolving to a view controller method should be appearing in a near-future release"

    Also your Architect is using lots of memory and hangs after some time. I use the latest version of the Architect and have lots of memory on my PC (32Gb RAM).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •