Results 1 to 3 of 3

Thread: [RESOLVED] Order/Structure for events?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2008
    Location
    PA
    Posts
    365

    Resolved [RESOLVED] Order/Structure for events?

    I am handling mouse and keyboard actions via OpenTK. Depending on other classes and the interfaces they implement, I am passing the correlating events through.

    I just ran into a problem in which mouse events can trigger two different scenarios: MouseUp and Click. Should one fire before the other? Should the MouseUp event not even be fired if I'm firing the click event? What are your opinions?

    Code:
    protected override void OnMouseUp (MouseButtonEventArgs e)
    		{
    			base.OnMouseUp (e);
    			if (FocusControl != null)
    			{
    				if (typeof(IMouseable).IsInstanceOfType (FocusControl))
    				{
    					((IMouseable)FocusControl).OnMouseUp (e);
    				}
    				if (!mouseMove) //the mouse was down then up without it moving in between
    				{
    					if (typeof(IClickable).IsInstanceOfType (FocusControl))
    					{
    						//click it
    						((IClickable)FocusControl).Click();
    						if(LastClickedFocusControl != null)
    							LastClickedFocusControl.ClickedFocus = false;
    						FocusControl.ClickedFocus = true;
    						LastClickedFocusControl = FocusControl;
    					}
    				}
    			}
    			//reset all the mouse bools
    			mouseDown = false;
    			mouseMove = false;
    		}
    The same could be incorporated for KeyPress and KeyDown/Up events, although I seem to have a handle on that using KeyPress mostly, and KeyDown/Up only for special presses like BackSpace's.

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: Order/Structure for events?

    All of the relevant events should fire. And they should fire off in the same and predictable order: MouseDown, MouseUp, MouseClick. I believe that's the same order in which Windows sends & processes those same events.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2008
    Location
    PA
    Posts
    365

    Re: Order/Structure for events?

    It sounds like I'm ok leaving it as is then. Thanks for the insight TG!

Posting Permissions

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



Click Here to Expand Forum to Full Width