Page 1 of 1

Mouse Behavior lost after certain actions

Posted: Sun May 08, 2011 7:33 am
by dglass
That subject is pretty bad, but I don't know how else to describe the issue. :oops:

I have a multi-paned interface with one horizontal splitter, and one vertical splitter. The code for the horizontal splitter looks like this:

Code: Select all

on mouseenter
   if the tool is "browse tool" then
      lock cursor
      set the cursor to 64
   end if
   
end mouseenter

on mouseleave
   if the tool is "browse tool" then
      unlock cursor
   end if
   
end mouseleave

on mousemove
   if the tool is "browse tool" then
      repeat until the mouse is up
         if item 2 of the mouseloc > 196 and item 2 of the mouseloc < 584 then
            set the loc of me to item 1 of the loc of me, item 2 of the mouseloc
            --rect = left, top, right, bottom
            --adjust the stuff above the splitter
            set the rect of group "DataGrid 2" to the left of group "DataGrid 2", the top of group "DataGrid 2", the right of group "DataGrid 2", the top of me
            --adjust the stuff below the splitter
            set the rect of group "DataGrid 3" to the left of group "DataGrid 3", the bottom of me, the right of group "DataGrid 3", the bottom of group "DataGrid 3"
         end if
         
      end repeat
   end if
   
end mousemove
This works as expected, and the code for the vertical splitter is the same (with obvious changes for resizing the vertical instead of the horizontal).

The problem is that after doing any resizing -- so the stuff in 'mousemove' has finished, and the cursor has been unlocked (mouseleave) -- the mouse stops behaving:

1. the cursor will not change if I move the mouse into the splitter control (mouseenter)
1.1 clicking anywhere in the card/window 'wakes' the cursor up, and the mouseenter code will then fire when appropriate.

2. the first click is swallowed by...something. I haven't figured out where it goes. It doesn't matter where I click, the click doesn't seem to register.
2.1. I can click on the Edit button, and I am not released from Browse mode until I click the Edit button a second time.
2.2. If I try to click on the code editor hiding behind the active card, it does not come to the front until I click it again.

Interestingly, if I ignore that the cursor hasn't visibly changed, and drag the splitter around, it does move (and the cursor changes when the splitter first starts to move), and then when I release the mouse button the cursor behaves properly so I can immediately put the cursor in the splitter and the cursor changes. Until I do it again, and then I'm back to the behavior above. So it almost works out to 'every other time it's right.' :?

This description isn't much better than the subject, but I'm not sure how else to describe the behavior I'm seeing.

Re: Mouse Behavior lost after certain actions

Posted: Mon May 09, 2011 6:21 am
by dglass
Help from the mailing list resulted in this:

Code: Select all

on mousedown
if blnDown then
...do stuff
end if
end mousedown
not this:

Code: Select all

on mousedown
repeat until the mouse is up
...do stuff
end repeat
end mousedown
The first one requires a local variable/flag to track the down status of the mouse, and setters in the various mouse handlers (down, release, up, leave).

Thanks Terry Judd! :D

Re: Mouse Behavior lost after certain actions

Posted: Mon May 09, 2011 9:06 am
by Dixie
Terry...

lock the cursor after you have made the change, not before.

Code: Select all

on mouseEnter
   /* set the cursor to a 'drag' icon */
   set the cursor to 6200
   lock cursor
end mouseEnter

on mouseLeave
   unlock cursor
end mouseLeave

on mouseDown
   .... do whatever
   unlock cursor
end mouseDown
be well

Dixie

Re: Mouse Behavior lost after certain actions

Posted: Mon May 09, 2011 3:43 pm
by dglass
I'm not Terry. Terry helped me. :)

As to the 'lock cursor', it appears to work as I have it, so is that just coincidence?

Re: Mouse Behavior lost after certain actions

Posted: Mon May 09, 2011 7:29 pm
by jacque
As to the 'lock cursor', it appears to work as I have it, so is that just coincidence?
The order doesn't really matter as long as both commands are in the same handler. Locking the cursor just prevents the engine from changing the cursor at pre-determined events. You can always change it via script.