1. #1
    Sencha User
    Join Date
    Jan 2009
    Location
    Ottawa, ON, Canada
    Posts
    81
    Vote Rating
    0
    Answers
    6
    myExtJsUname is on a distinguished road

      0  

    Default Unanswered: Ext.tree.Panel itemdblclick thwarted by addition of itemclick listener

    Unanswered: Ext.tree.Panel itemdblclick thwarted by addition of itemclick listener


    Hello all,

    By default, a double-click on an expandable tree node causes it to expand/collapse. However, once I introduce an itemclick listener, that event is "swallowed up" by two itemclick events and never runs again, no matter how quick the user clicks. As suggested in other threads, I've looked into using the select instead, but that has different problems for what I'm trying to do; namely, a second click (not a double-click in this case) on the same node doesn't fire the select event because it's already selected, among others. So, if anyone can suggest a way to go about what I am trying to accomplish, I'd appreciate hearing from you.

    Each node in our Ext.tree.Panel has a checkbox. We would like an "itemclick" to toggle the checkbox status. We would also like to provide the default itemdblclick functionality noted above. The double-click, however, should not toggle the checkbox status...only expand/collapse the node as appropriate.

    Is this easily accomplished in some way I haven't discovered within the Ext.tree.Panel? If not, I was thinking some delay was necessary in the itemclick handler to know whether the event it's dealing with is actually an itemclick or an itemdblclick, but after looking into this for a while, I'm pretty sure that's too complicated for me to implement. If there isn't something here already that I'm just missing, I'm happy to stop beating my head against the wall over it. We're willing to forego the itemdblclick expand/collapse functionality and require the user to use the expand icon instead in order to have the checkbox status toggle on the itemclick. But, just in case there is something I can do, I thought I'd ask in the forums.

    Any comments, information or direction in this regard are welcome.

    cheers,
    jtm

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    34,107
    Vote Rating
    453
    Answers
    3156
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    I often will save when the last click was done as a property (new Date().getTime() ) and then check that in each click. If it was within so many milliseconds I consider it a double-click
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Jan 2009
    Location
    Ottawa, ON, Canada
    Posts
    81
    Vote Rating
    0
    Answers
    6
    myExtJsUname is on a distinguished road

      0  

    Default


    And then, you will trigger the itemdblclick yourself from within the itemclick handler?

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    34,107
    Vote Rating
    453
    Answers
    3156
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    You only need 1 listener at that point so just the itemclick event.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User
    Join Date
    Jan 2009
    Location
    Ottawa, ON, Canada
    Posts
    81
    Vote Rating
    0
    Answers
    6
    myExtJsUname is on a distinguished road

      0  

    Default


    Thank you, Mitchell, for taking the time to respond to my query. I have to be honest, though, and say that I may not be following what you are suggesting. So, if you don't mind, I'd like to go over what I think you are recommending.

    I thought you were suggesting that I keep track in the itemclick handler when a given itemclick event occurred and set up some kind of delay so I can see if a second click has occurred within a predefined (small) period of time after which I would determine whether the itemclick or itemdblclick functionality should be invoked. If no second click is received, the code would carry on and perform the itemclick functionality (in my case, toggle the checkbox status) and, if a second click is received, I would cancel the "itemclick" that's waiting and fire an "itemdblclick" on the tree panel that would invoke the default expand/collapse behaviour.

    Am I understanding you correctly?