Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Controls Leave Event - Help

Controls Leave Event - Help

Scheduled Pinned Locked Moved C#
help
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Craig G Fraser
    wrote on last edited by
    #1

    Hi, Is there anyway of differentiating whether a controls Leave event was fired by a "TAB" out of the control or by a "Mouse Move" out of the control. I am trying to pop-up a window whent he user "tabs" out of a control which is fine but it is also happening when they "mouse move" out of the control. I am using the controls Leave event. Any help will be greatly appreciated. Thanx Craigo

    W 1 Reply Last reply
    0
    • C Craig G Fraser

      Hi, Is there anyway of differentiating whether a controls Leave event was fired by a "TAB" out of the control or by a "Mouse Move" out of the control. I am trying to pop-up a window whent he user "tabs" out of a control which is fine but it is also happening when they "mouse move" out of the control. I am using the controls Leave event. Any help will be greatly appreciated. Thanx Craigo

      W Offline
      W Offline
      Wjousts
      wrote on last edited by
      #2

      I would imagine (although I haven't tried this) you could intecept both the MouseMove and the KeyDown events for your control then in the KeyDown event check for the tab key and if it was pressed set a flag, lets call it TabPressed, to true (else false). In the MouseMove event you would set TabPressed to false. When your control Leave event fires you can then check if TabPressed is true and pop-up your window if it is, else don't.

      C 1 Reply Last reply
      0
      • W Wjousts

        I would imagine (although I haven't tried this) you could intecept both the MouseMove and the KeyDown events for your control then in the KeyDown event check for the tab key and if it was pressed set a flag, lets call it TabPressed, to true (else false). In the MouseMove event you would set TabPressed to false. When your control Leave event fires you can then check if TabPressed is true and pop-up your window if it is, else don't.

        C Offline
        C Offline
        Craig G Fraser
        wrote on last edited by
        #3

        Thanx for the reply....the problem is that you cannot trap the Tab key on the KeyDown event becase when you press the tab key it doesnt fire the keydown event, only the OnLeave event fires.

        W 1 Reply Last reply
        0
        • C Craig G Fraser

          Thanx for the reply....the problem is that you cannot trap the Tab key on the KeyDown event becase when you press the tab key it doesnt fire the keydown event, only the OnLeave event fires.

          W Offline
          W Offline
          Wjousts
          wrote on last edited by
          #4

          Hmmm....what if you set the KeyPreview property of the form that contains your control to true and handle the KeyDown event there? Will that let you see the KeyDown before the OnLeave event? -- modified at 9:47 Tuesday 18th October, 2005 Actually, another thought. Perhaps you could check the mouse position using Cursor.Position in your OnLeave event and check to see if it is within your control or not? Or better yet (maybe) perhaps you need to handle the MouseEnter and MouseLeave events for your control. Keep a flag (set on the MouseEnter and MouseLeave events) of whether the mouse is within the control. When the control first gets focus store the current state of that flag. On your OnLeave event check to see if the current flag state indicates that the mouse is outside the control where before it was inside. There are some details there that you'd have to work out, but it's something to think about.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups