App pause while dragging window

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

croivo
Posts: 111
Joined: Wed Feb 26, 2014 11:02 pm

App pause while dragging window

Post by croivo » Fri Mar 28, 2014 8:49 pm

I have simple count up code for my clock, and it works good but when I click (and hold or move) on border of the window it pause counting up until I release mouse click. How to 'fix' this to work ALL the time?
Here is my code:

Code: Select all

set the numberformat to 00
      add 1 to field ClockSec of card controller
      if field ClockSec of card controller = 60
      then
         add 1 to field ClockMin of card controller
         put 00 into field ClockSec of card controller
      else
      end if

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10066
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: App pause while dragging window

Post by FourthWorld » Fri Mar 28, 2014 8:57 pm

Can we see the full handler?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

croivo
Posts: 111
Joined: Wed Feb 26, 2014 11:02 pm

Re: App pause while dragging window

Post by croivo » Fri Mar 28, 2014 8:59 pm

Code: Select all

on mouseUp
   If the label of ME is "Start" then
      set the label of ME to "Stop"
      set the backgroundcolour of ME to red
         DoCountUp
   else 
      set the label ME to "Start"
      set the backgroundcolour of ME to green
   end if
end mouseUp

on DoCountUp
   if label of ME is "Stop"
   then
      set the numberformat to 00
      add 1 to field GameClockSec of card controller

      if field GameClockSec of card controller = 60
      then
         add 1 to field GameClockMin of card controller
         put 00 into field GameClockSec of card controller
      else
      end if
      send "DoCountUp tNewTime" to me in 1 second
   end if
end DoCountUp

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: App pause while dragging window

Post by Mark » Fri Mar 28, 2014 9:03 pm

Hi,

You can't do what you want. When you drag a window, the IDE locks up until you release the mouse. However, there are smarter ways to update a time display. Here's an example:

Code: Select all

local lStartTime

on updateTime
  if lStartTime is empty then
    put the seconds into lStartTime
  end if
  put the seconds - lStartTime into myLapsedSeconds
  put myLapsedSeconds div 60 into myMinutes
  put myLapsedSeconds mod 60 into mySeconds
  put myMinutes & colon & mySeconds into fld "Time"
  // there are better ways to do this, but this is just an example
  send "updateTime" to me in 500 milliseconds
end updateTime

on stopTime
  put the pendingMessages into myMessages
  filter myMessages with "*updateTime*"
  repeat for each line myMsg in myMessages
    cancel item 1 of myMsg
  end repeat
end stopTime
Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: App pause while dragging window

Post by Mark » Fri Mar 28, 2014 9:06 pm

Hi again,

Starting from your moueeUp handler:

Code: Select all

on mouseUp
   If the label of ME is "Start" then
      set the label of ME to "Stop"
      set the backgroundcolour of ME to red
      updateTime
   else
      set the label ME to "Start"
      set the backgroundcolour of ME to green
      stopTime
   end if
end mouseUp
If you use my example, you'll need a field with the name "Time".

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

croivo
Posts: 111
Joined: Wed Feb 26, 2014 11:02 pm

Re: App pause while dragging window

Post by croivo » Fri Mar 28, 2014 9:07 pm

Thanks Mark!
Can this maybe be new feature request for new version of LiveCode?

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

Re: App pause while dragging window

Post by jacque » Sat Mar 29, 2014 7:37 pm

It is possible to respond to a window drag. Use a moveStack handler to send an update to your time field when that happens:

Code: Select all

on moveStack
  updateTime
end moveStack
You should use Mark's updateTime calculation because it calculates the correct time increase based on the current time, which will prevent errors in the time display.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

croivo
Posts: 111
Joined: Wed Feb 26, 2014 11:02 pm

Re: App pause while dragging window

Post by croivo » Thu Apr 16, 2015 10:08 pm

Is there any handler that detects when the mouse has clicked on title bar of stack? moveStack works only when stack is moving...

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

Re: App pause while dragging window

Post by jacque » Fri Apr 17, 2015 4:22 pm

croivo wrote:Is there any handler that detects when the mouse has clicked on title bar of stack? moveStack works only when stack is moving...
Not really. What do you need to do?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10394
Joined: Wed May 06, 2009 2:28 pm

Re: App pause while dragging window

Post by dunbarx » Fri Apr 17, 2015 4:39 pm

Even "mouseMove" is not sent when the cursor is outside the rect of the card window, or that could be exploited. I wonder if that would be a nice feature, to have it in fact do so.

Anyway, I am with Jacque; what are you looking to do?

Craig Newman

Klaus
Posts: 14267
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: App pause while dragging window

Post by Klaus » Fri Apr 17, 2015 6:15 pm

Hi all,

maybe the "moveStack" message can help here?
This is sent to the current card while the user drags the stack window!


Best

Klaus

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

Re: App pause while dragging window

Post by jacque » Fri Apr 17, 2015 7:39 pm

The OP eliminated the movestack option:
moveStack works only when stack is moving...
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Klaus
Posts: 14267
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: App pause while dragging window

Post by Klaus » Fri Apr 17, 2015 8:13 pm

jacque wrote:The OP eliminated the movestack option:
moveStack works only when stack is moving...
I promise to read and understand the complete thread the next time! 8)

croivo
Posts: 111
Joined: Wed Feb 26, 2014 11:02 pm

Re: App pause while dragging window

Post by croivo » Sat Apr 18, 2015 11:46 am

I have some count up timers in my stack and when you click on the title bar of an app, it pauses the count up timer. So I thought maybe I can do that count up code when the mouse is down on title bar...

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

Re: App pause while dragging window

Post by jacque » Sat Apr 18, 2015 7:00 pm

I don't see any pause when I run a test handler on my Mac. What OS are you on? Also, post your count-up handler and we can look.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply