SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to lock key and mouse events on one element?

    Hi guys,

    I'm trying to figure out a way to make only one element on a page receive key and mouse events. I have a grid in a <div>-container with "overflow:auto" which makes the grid scrollable. If course I can set event handlers to the "document" to catch key strokes and mouse clicks and execute navigation functions which make the grid scroll (e.g. pressing down arrow) etc. This of course effects the whole page and not just the div.

    The problem is: as far as I know only window and form elements can receive events such as focus(), blur(), keypress() etc. and I have to make sure only this one element is affected.

    Is there thus a way to make these events affect only the <div> container?


    The best way to do this would be with an event listener as this would make development much easier.

    Has someone done this before?

    Thanks for your help

    Cheers, Florian

  2. #2
    SitePoint Addict ALL's Avatar
    Join Date
    Oct 2005
    Location
    South Dakota
    Posts
    215
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    what you can do is make catch all the user actions... then have the script check to see if the div is where the mouse is or... if an element in the div is taking the action.

    BTW... it can be a chore trying to get this to work with the big browsers because they use different ways of sending events to js... just to let you know.

    -ALL
    Did I help you?
    You can repay me, support one of my projects (no money needed):
    JavaScript Wiki, Another Web Forum, Paranormal Site


Bookmarks

Posting Permissions

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