1. #1
    Ext JS Premium Member
    Join Date
    May 2008
    Posts
    534
    Vote Rating
    0
    Eric24 is on a distinguished road

      0  

    Default Detecting click anywhere on the Viewport

    I have an Ext 3.x app that uses a fairly complex border layout as its Viewport. Is there a simple way to detect a mouse click anywhere on the Viewport (i.e. without attaching click listeners all over the place)? I still want the click to do whatever it would normally do when clicking on the various widgets that are in the Viewport (i.e. grid, tree, toolbars), but I need to "see" the click in a single function as well.

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,570
    Vote Rating
    53
    Animal will become famous soon enough Animal will become famous soon enough

      0  

    Default

    Code:
    Ext.getBody().on({
        click: ...
    });

  3. #3
    Ext JS Premium Member
    Join Date
    May 2008
    Posts
    534
    Vote Rating
    0
    Eric24 is on a distinguished road

      0  

    Default

    Yes, I had tried something similar using getEl() on the viewport. Both solutions work to an extent, but there is a problem: I need to tell the difference between a click on the viewport and a click on a window; the windows are part of the viewport, so I get the click event no matter what. I ended up fixing that using a findParent call in the click event handler, looking for div.x-window. Maybe there's an easier/better way?

  4. #4
    Sencha User
    Join Date
    Sep 2014
    Posts
    23
    Vote Rating
    -5
    MrFox can only hope to improve

      0  

    Default

    Have you tried listening for clicks on the child views as well? Maybe they will hit first and then bubble up to the parent. That behavior can be cancelled with something like cancel bubble.https://www.sencha.com/forum/showthr...work.Won't you get the view that caused the event? Especially if you listen to the event on sencha components, you should be able to check the xtype.

Similar Threads

  1. Detecting Phone/OS
    By kgmoney in forum Sencha Touch 1.x: Discussion
    Replies: 4
    Last Post: 8 Feb 2012, 7:51 AM
  2. Detecting Escape
    By silcreval in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 6 Jun 2010, 12:06 PM
  3. viewport handling all click events
    By emredagli in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 26 Nov 2008, 12:03 PM
  4. detecting browser
    By Vankir in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 27 Oct 2008, 11:53 PM

Thread Participants: 2