Mouse Control Sticking

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
runrevGAf68e
Posts: 22
Joined: Mon Dec 19, 2011 1:12 pm

Mouse Control Sticking

Post by runrevGAf68e » Sun Jan 15, 2012 5:33 am

I'm trying out LiveCode Game Academy. I'm having trouble with the LiveCode application itself. It seems to keep losing the position of the mouse button as I interact with the windows.

For example, it sometimes seems to think I have not released the mouse. So, I can't get out of drag mode (moving an element on the screen). Or, I will click somewhere and click again. LiveCode seems to think the mouse has been pressed down the whole time and will highlight the section of code in between.

It gets so bad that I can't even closed "cards" or click on dialog boxes that open. Eventually, my fan starts whirring and I'm at 100% CPU.

I couldn't find a better place to post this.

Mac : OS 10.7.2
8 GB RAM
2.53 GHz Core i5

LiveCode 5.0.2 in trial mode.

I've rebooted the machine and tried again. I get the same problem. Needless to say, this makes evaluating LiveCode pretty tough. If I can't resolve this, I will need to move on to some other development tool.

Any suggestions?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7392
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Mouse Control Sticking

Post by jacque » Sun Jan 15, 2012 10:11 pm

This sounds like a script gone wild in the stack you're working with. Can you reproduce the problem in a new, empty stack?

There may be a script somewhere that is sending repeated messages too quickly for anything else to happen. I haven't looked at it, but I believe the game academy stack uses pending messages. If it happens again, open the Pending Messages pane in the message box and cancel all pending messages. That should clear out the queue and return control. Then you need to figure out what in the script is causing the problem.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Mouse Control Sticking

Post by sturgis » Sun Jan 15, 2012 10:58 pm

If you're trying to drag stuff around while the gameloop is running there might be problems cropping up from that also.
Might be other things going on here too but..

If you're trying to drag things, in your updatescreen handler you can check for the mousedown, look at "the target" and if its an object you want to be dragable, place its long id or name or something into a script local variable. Then "set the loc of button yourvariablewithbuttonname to the mouseloc"

if the mouse is NOT down, clear the variable.

Heres a quick example. I created a button that I want to be drag-able. In its script I put the following.

Code: Select all

on mouseUp
   clearDragable -- calls a handler in the card script. 
end mouseUp

on mousedown
   setDragable (the short name of me) -- same. This handler sets a variable to the name of this button
end mousedown
The 2 handlers in the card script are here.
The sDragging variable should be declared as a script local at the top of the card script.

Code: Select all

command clearDragable
   put empty into sDragging -- clears the variable when the mouse is let up
end clearDragable

command setDragable pId
   put pId into tDragging -- puts the name of the button that called this handler into variable sDragging
end setDragable
Then, to allow the button to be draggable I added the following to the updatescreen handler.

Code: Select all

   if the mouse is down and tDragging is not empty then -- is the mouse down AND has the variable been set with the name of the object to drag
         set the loc of button tDragging to the mouseloc -- if so, drag the button. 
      else
         put empty into tDragging -- otherwise something weird happened so clear tDragging just because. 
      end if

For a quick test it seems to work fine.

Post Reply