From: Mark M. <mie...@gm...> - 2012-01-04 22:03:39
|
On Wed, Jan 4, 2012 at 1:16 PM, Oliver Sims < oli...@si...> wrote: > ** > I'm getting my head around the mouse behavior. The onLButtonDown method > (first several lines only) in mouseTrack.rex is as follows: > > ::method onLButtonDown unguarded > expose oldCursor dragMouse mouseIsNoMouse dragging > use arg keyState, mousePos, mouse > say 'Got lButton down' > if mouse~dragDetect(mousePos) then do > say 'Detected dragging' > mouse~capture > > I notice that the mouse's dragDetect(mousePos) method sends the dialog an > onCaptureChange message which (in your sample code) does nothing. > Control then returns to the mouse~capture statement. > > My question is this: after the onLButtonDown method is invoked, under what > circumstances would mouse~dragDetect NOT return .true? > The simplest case would be when the user clicked the left mouse button. Recall, or realize, that the onLButtonDown() method will be invoked when the user presses the left mouse button down. If the user immediately releases the button, the user didn't mean to drag something, it was just a click. You can gain some more insight by googling 'MSDN DragDetect' DragDetect is a Windows API to help with dragging. The ooDialog dragDetect() just gives you access to that API. What the OS does, is capture the mouse input and tracks the mouse until the user releases the button, (or presses escape), or the mouse position moves outside the drag rectangle. If the button is still down when mouse leaves the drag rectangle, the the OS assumes, "yes the user is trying to drag." Otherwise, with a 'drag aware' program every time the user pressed the mouse button down a drag operation would start. (It is almost impossible for a person to press the mouse button without moving it a minute amount before the button is released.) By the way, I was never able to detect the mouse capture part of that. Either I jiggle the mouse more than you do, or something. The system drag rectangle is configurable. Getting and setting the drag rectangle is something I'll add in the future. To be technically nit picky: I notice that the mouse's dragDetect(mousePos) method sends the dialog an onCaptureChange message Actually, the OS generates a mouse capture message every single time the capture changes. The DragDetect() API simply captures the mouse, it has nothing to do with generating the message, and the dragDetect() method really has nothing to do with it. Good question, this is the type of discussion I was hoping users of ooDialog would engage in. Also, mouseTrack.rex was really just an exploratory program I used when I was first implementing the Mouse class. Be sure and get the latest switch ooDialog beta off of SourceForge, the Mouse class may have undergone some changes after I wrote mouseTrack.rex. Also the latest code has dragNdrop.rex that is a more polished example of the Mouse class methods. -- Mark Miesfeld |